Structures are handy if you have a certain set of types of information that will be used repeatedly. For example, a structure called 'address' might consist of the street number, the city, the zip code, the state, and the country. You could then create several instances of this structure, maybe for several employees or something. Each instance would have its own zip code, state, country variable etc.
C structures allow a programmer to combine variables related to a concept into one block. For instance, if you wanted to declare variables relating to a vehicle, you could use the following:
char *vehicle_make, *vehicle_model;
int vehicle_year;
enum { color_red, color_blue, color_green, color_gold, color_silver } vehicle_color;
vehicle_make="Slodge";
vehicle_model="Guzzler";
vehicle_year=2010;
vehicle_color=color_gold;
However, sometimes you'll want to maintain multiple vehicles in memory at once. Using the above method, you'd have to employ something like the following block:
char *vehicle1_make, *vehicle1_model;
int vehicle1_year;
enum { color_red, color_blue, color_green, color_gold, color_silver } vehicle1_color;
char *vehicle2_make, *vehicle2_model;
int vehicle2_year;
enum { color_red, color_blue, color_green, color_gold, color_silver } vehicle2_color;
And so forth. This can get very messy. Instead, you can use the 'struct' declaration as follows:
enum vehicle_color { color_red, color_blue, color_green, color_gold, color_silver };
struct vehicle {
char *make, *model;
int year;
vehicle_color color;
};
struct vehicle vehicle1, vehicle2;
vehicle1.make="Slodge";
vehicle1.model="Guzzler";
vehicle1.year=2010;
vehicle1.color=color_gold;
Now that you have a struct, you can also write a function that automatically sets a vehicle's members in one statement:
void vehicle_set(struct vehicle *vehicle, char *make, char *model, int year, vehicle_color color)
{
vehicle->make=make;
vehicle->model=model;
vehicle->year=year;
vehicle->color=color;
}
vehicle_set(&vehicle1, "Slodge", "Guzzler", 2010, color_gold);
Keep in mind that if you use pointers in structures like I did above, and you begin working with files, then writing vehicle1 to a file instead of its individual members means you'll write the pointers to the variables, and not the variable data, to files.
See the related links below for more information on C in tutorial format.
by using structure in c.........
A tree.
There is no part called 'loader' in C language.
C is a pop language. C is a case sensetive language. C is motherof all language. C is block structure language. C is a high level language. C is advace of B language. C developed by D.richties in 1972 at AT & T Bell lab in USA. Sachin Bhardwaj 986854722 skbmca@gmail.com
c language is the structure oriented language and c does not follows the object oriented paradigms . c++ obeys the all object oriented language characteristics ========== C++ is a set of extensions to the C language to allow some (not all) principles of object-oriented programming to be used. Originally, C++ was a front end pre-processor for C and C++ compilers will translate C language functions.
Structure is a query that is used in language c++
by using structure in c.........
a synonym for structure language in "Comb-sturctured" languages. C in comb.
I do use am a programmer, because C-language.
A tree.
There is no part called 'loader' in C language.
C is a pop language. C is a case sensetive language. C is motherof all language. C is block structure language. C is a high level language. C is advace of B language. C developed by D.richties in 1972 at AT & T Bell lab in USA. Sachin Bhardwaj 986854722 skbmca@gmail.com
TO use a c language first step is to know about the c language and the steps to use the c progrmming language with the help of any elders or with the teachers. TO use the arrays you have to get th eknowledge of "c" language
open, read/write, close
c language is the structure oriented language and c does not follows the object oriented paradigms . c++ obeys the all object oriented language characteristics ========== C++ is a set of extensions to the C language to allow some (not all) principles of object-oriented programming to be used. Originally, C++ was a front end pre-processor for C and C++ compilers will translate C language functions.
The fundamental difference is that in C++ object-oriented programming (OOP) was added. C is a procedural language (that means. top-down structure design), where as C++, which is an extension of C itself, is an object oriented language.
To run C language?! Your question makes no sense.