Presentation is loading. Please wait.

Presentation is loading. Please wait.

Structures in c By Anand George.

Similar presentations


Presentation on theme: "Structures in c By Anand George."— Presentation transcript:

1 Structures in c By Anand George

2 Structures Very similar to arrays.
Array contains same type of elements Structures contain different type of elements. Like a wallet or bag which has many different things in it.

3 Use of structure Think about in the program represent on a employee of a company. Had name, id, address. Name is a string type data. Id is integer type data Address is again string. Array wont fit Has to be a structure

4 Initialization struct myTestStruct { int a; char b; short c; int d; };
void main() myTestStruct mts = { 1, 2, 3, 4 }; }

5 Example struct Student { char name[100]; int studentId; char address[300]; };

6 Accessing elements Dot operator

7 Demo Accessing structure element with dot operator.

8 Demo Saving the name, id, and address of 5 students and printing it out. Sort the list with name of the student and print it.

9 Thank you


Download ppt "Structures in c By Anand George."

Similar presentations


Ads by Google