The above example shows that the struct be named "box" with the data field length, width and area.
Benefits struct data type is basically to save the package (set) data into one variable name. Collection of data is collected into one and can have a data type variety. When naming struct, get used to form a unity of meaning with is struct, for example if it struct named struct box then its contents are: length, width, and area.
To accommodate some of the data, struct is usually combined with the Array, for example inisialisasi as follows:
struct mahasiswa {
int nim;
char nama[20];
float IPK;
} data[5];
int nim;
char nama[20];
float IPK;
} data[5];
Example initialization struct is named "student" with nim data fields, name and GPA. While the variable name is made of the data array of size 5. It means we will create an array to accommodate as many students struct data 5. The concept is usually coupled with a logic array for data storage is not possible only a single data store, but certainly more than one data, for example as follows:
initialization struct called "students" with nim data entries, the name and GPA. While the variable name is made of the data array of size 5.
No comments:
Post a Comment