Structure is a user define data-type in C language. Structure holds different type elements.
Each element of structure is called member.
struct is a keyword.
Syntax
struct structure_name{
data-type member-variable-1;
data-type member-variable-2;
data-type member-variable-3;
...........
...........
};
example:
struct student{
char stName[100];
char stMob[15];
char stAddress[300];
};
In above example "student" is the name of structure. stName, stMob, stAddress are member of structure.
There are two ways to declare structure variable.
(1.) with structure body.
(2.) In main() function.
Syntax
struct structure_name{
data-type member-variable-1;
data-type member-variable-2;
data-type member-variable-3;
...........
...........
}struct_variable1, sruct_variable2,......;
example:
struct student{
char stName[100];
char stMob[15];
char stAddress[300];
}st1,st2;
In above example st1 and st2 are structure type variable.
Syntax
struct structure-name variable;
example:
struct student st1,st2;
There are two ways to access structure members:
(1)By . (member or dot operator)
(2)By -> (structure pointer operator)
Comsysapp.com is an educational website. Students and software developers can learn programming language tutorials. Comsysapp is very useful for beginners and professional developers. Comsysapp provides tutorial in easy language. Comsysapp.com has focus on simplicity.
Comsysapp.com provides free tutorials like c, html, css, etc. All tutorials are free for beginner and professionals.
comsysapp.com is not responsible for any mistake. We are not responsible if information made available on our website is incomplete or invalid. But comsysapp.com always try for zero-zero mistake.
comsysapp.com does not collect any data from users. We use Google AdSense advertising on our website. We never ask personal or private information.
copyright © 2023