Thread: Storing array of structures in C

  1. #1
    Registered User
    Join Date
    Apr 2013

    Storing array of structures in C

    So i have a program with the structure
    char  record[20];
    typedef struct{
    int id;
    char title[20];
    char subject[20];
    char faculty [20];
    int level;
    char fname[25];
    int recno,i;
    report list[100];
    I need to store the hundred records into a file.I searched a lot in the internet and my notes but i got confused.Please tell me about the functions and elements i should use/introduce. thanks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Well, if you had a single report, you would have

    report student;
    For an array, this becomes
    report students[100];
    for ( i = 0 ; i < 100 ; i++ ) {
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2013
    Its often the simple things we wonder about..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 08-11-2011, 02:37 PM
  2. 2D array storing
    By anirban in forum C Programming
    Replies: 1
    Last Post: 07-22-2009, 07:16 PM
  3. Storing an array of structures?
    By Sparrowhawk in forum C Programming
    Replies: 4
    Last Post: 12-15-2008, 03:07 AM
  4. Storing in an Array
    By peckitt99 in forum C++ Programming
    Replies: 24
    Last Post: 10-10-2006, 01:01 AM
  5. Structures, passing array of structures to function
    By saahmed in forum C Programming
    Replies: 10
    Last Post: 04-05-2006, 11:06 PM