Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- //Declaring outer and inner structure
- struct student
- {
- //main structure
- char name[50];
- int age;
- struct uni_info
- {
- //inner structure
- char uni_name[50];
- int uni_id;
- }uni_info[20]; //variable for nested structure
- }stu_info[20]; // variable for main structure
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- char ch;
- scanf("%s",&stu_info->name); //take name
- scanf("%c",ch); //clear buffer
- scanf("%d",&stu_info->age); //take age
- scanf("%s",&stu_info->uni_info->uni_name); //take nested structure uni name
- scanf("%c",ch); //clear buffer
- scanf("%d",&stu_info->uni_info->uni_id);
- printf("%s\n%d\n%s\n%d",stu_info->name,stu_info->age,stu_info->uni_info->uni_name,stu_info->uni_info->uni_id);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement