468,306 Members | 1,234 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,306 developers. It's quick & easy.

structure problem

i have done the following program of student information.
when we run the program we enter details of all the 10 students
and get output details of all the 10students.
now if we come out of the program i.e execution of program is completed and again we come to the sourse code of the program.
now my question is what should i do if i have to view the details of
all the 10 students whose information i have entered earlier?
is this information (details of 10 students) get stored anywhere?
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. struct student
  4.    {
  5.    char name[20];
  6.    int roll,age;
  7.    };
  8. main()
  9.    {
  10.    int i;
  11.    struct student S[10];
  12.    clrscr();
  13.    for(i=0;i<3;i++)
  14.       {
  15.       printf("\nEnter the details of the student : ");
  16.       scanf("%s %d %d",S[i].name,&S[i].roll,&S[i].age);
  17.       }
  18.    clrscr();
  19.    printf("\nThe details of the student are\n");
  20.    for(i=0;i<3;i++)
  21.       {
  22.       printf("\n%s \n%d \n%d\n\n",S[i].name,S[i].roll,S[i].age);
  23.       }
  24.    getch();
  25.    return 0;
  26.    }
Jan 24 '07 #1
1 756
horace1
1,510 Expert 1GB
you need to open an output file and write the records to it, e.g.using fwrite()
http://www.cplusplus.com/reference/clibrary/cstdio/fwrite.html

then you can use fread() to read them back later
http://www.cplusplus.com/reference/clibrary/cstdio/fread.html
Jan 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Muhammad Farooq-i-Azam | last post: by
3 posts views Thread by Leo Nunez | last post: by
2 posts views Thread by Steve Turner | last post: by
11 posts views Thread by Lance | last post: by
3 posts views Thread by =?Utf-8?B?Umljb2hEZXZlbG9wZXI=?= | last post: by
3 posts views Thread by =?Utf-8?B?TWluZ3lp?= | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.