Initialization & Accessing Structure Members in C

C programming language treats a structure as a user-defined data type; therefore you can initialize a structure like a variable. Here is an example of initialize product structure: struct product { char name[50]; double price; } book = { “C programming language”, 40.5 }; In above example, we defined product structure, then we declare and … Read more

Structure Declaration in C

The first way is to declare a structure variable immediately after the structure definition, as follows: struct address { int house_number; char street_name[50]; int zip_code; char country[50]; } struct_var1, struct_var2; In the second way, you can declare the structure variable at a different location after structure definition. Here is structure declaration syntax: struct address { … Read more

Arrays in C

Imagine that you have to store and later retrieve the unique ID of all of the registered voters in your city. Yes, you can create and name hundreds of thousands of distinct variable names to store the information. However, that would scatter hundreds of thousands of names all over memory. In addition, there is a … Read more