Structure in c
-
Upload
baabtracom-mentoring-partner-first-programming-school-in-india -
Category
Education
-
view
730 -
download
1
description
Transcript of Structure in c
![Page 1: Structure in c](https://reader036.fdocuments.in/reader036/viewer/2022082603/547b3f435906b563798b45bd/html5/thumbnails/1.jpg)
![Page 2: Structure in c](https://reader036.fdocuments.in/reader036/viewer/2022082603/547b3f435906b563798b45bd/html5/thumbnails/2.jpg)
Structures in Cs
Fasalul [email protected]/Fasalul habeebtwitter.com/usernamein.linkedin.com/in/profilename9544962714
Typing Speed:19
![Page 3: Structure in c](https://reader036.fdocuments.in/reader036/viewer/2022082603/547b3f435906b563798b45bd/html5/thumbnails/3.jpg)
Structures In C
• A structure is a collection of one or more variables, possibly of different data types, grouped together under a single name for convenient handling.
• Structure declaration• Nested structures• Arrays of structures• Pointers to structures• Structures and functions
![Page 4: Structure in c](https://reader036.fdocuments.in/reader036/viewer/2022082603/547b3f435906b563798b45bd/html5/thumbnails/4.jpg)
Structure declaration• A structure type is usually defined near to the start of a file
using a typedef statement.
• typedef struct• { • char name[64]; • char course[128]; • int age; • int year; • } student;
![Page 5: Structure in c](https://reader036.fdocuments.in/reader036/viewer/2022082603/547b3f435906b563798b45bd/html5/thumbnails/5.jpg)
Nested structures • Structures can contain other structures as
members; in other words, structures can nest. Consider the following two structure types:
• struct first_structure_type { • int integer_member; • float float_member; • }; • struct second_structure_type { • double double_member; • struct first_structure_type struct_member; };
![Page 6: Structure in c](https://reader036.fdocuments.in/reader036/viewer/2022082603/547b3f435906b563798b45bd/html5/thumbnails/6.jpg)
Arrays of structures
• Just as arrays of basic types such as integers and floats are allowed in C, so are arrays of structures. An array of structures is declared in the usual way:
• struct personal_data my_struct_array[100];
![Page 7: Structure in c](https://reader036.fdocuments.in/reader036/viewer/2022082603/547b3f435906b563798b45bd/html5/thumbnails/7.jpg)
Pointers to structures
• A pointer to a structure types variable is declared by a statement such as the following:
• struct personal_data *my_struct_ptr;
![Page 8: Structure in c](https://reader036.fdocuments.in/reader036/viewer/2022082603/547b3f435906b563798b45bd/html5/thumbnails/8.jpg)
Example of structuer•
#include<stdio.h>
struct person{ char *name;int age;
• };
int main(){ struct person p;p.name = "John Smith";p.age = 25;printf("%s",p.name);printf("%d",p.age);return 0;
• }
![Page 9: Structure in c](https://reader036.fdocuments.in/reader036/viewer/2022082603/547b3f435906b563798b45bd/html5/thumbnails/9.jpg)
THE END
![Page 10: Structure in c](https://reader036.fdocuments.in/reader036/viewer/2022082603/547b3f435906b563798b45bd/html5/thumbnails/10.jpg)
If this presentation helped you, please visit our page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
![Page 11: Structure in c](https://reader036.fdocuments.in/reader036/viewer/2022082603/547b3f435906b563798b45bd/html5/thumbnails/11.jpg)
Contact Us
Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550
NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550
Start up VillageEranakulam,Kerala, India.
Email: [email protected]