In C, how to create a structure

www.la‮uttu‬ri.com
In C, how to create a structure

Let's create a structure variable 'student' as shown below.

//student structure
struct student {
  char id[15];
  char firstname[64];
  char lastname[64];
  float points;
};

Now we will create a student structure variable 'std'.

//student structure variable
struct student std;

Access the members of the structure

Use the Structure Member Operator ..

printf("ID: %s\n", std.id);
printf("First Name: %s\n", std.firstname);
printf("Last Name: %s\n", std.lastname);
printf("Points: %f\n", std.points);
Created Time:2017-08-28 06:31:43  Author:lautturi