Read multiple records from a file and store it in a structure

This is a discussion on Read multiple records from a file and store it in a structure within the C Programming forums, part of the General Programming Boards category; Hi, I need a program in C that is capable of writing the multiple records into a file.And another function ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    3

    Thumbs up Read multiple records from a file and store it in a structure

    Hi,
    I need a program in C that is capable of writing the multiple records into a file.And another function that should read the same data from the from the file and store it in the approptiate data structure.

    for eg:
    Code:
    typedef struct res
    {
    int res_type;
    char *res_name;
    char *res_loc;
    int priority;
    }res
    
    
    
    
    int store(int g_id,char *gname,struct res)
    {
    
    all these parameters should be stored in a file
     
    and return 1 if the storing is success
    and 0 if the storing is failed
    
    while storing if there is a repetition of g_id a error should be displayed.g id should be unique for each record
    }
    
    
    -----------------------------------------------------------------------------------------------------------------------------------------
    inside the file, informations should be stored like this
    -------------------------------------------------------------------------------------------------------------------------------------------
    g id :100
    g name:xyz
    res type:s/w
    res loc:c:/windows/pgm/a.txt
    res name:asd
    
    g id :210
    g name:yzs
    res type:s/w
    res loc:c:/windows/pgm/a.txt
    res name:acd
    
    g id :101
    g name:xss
    res type:s/w
    res loc:c:/windows/pgm/a.txt
    res name:aza
    
    ------------------------------------------------------------------------------------------------------------------------------------------
    
    
    struct read()
    {
    
    read should be capable of retrieving each record(i.e, g id,gname ,res type,res loc,res name) and store it in  a structure and should return the structure to the calling function
    
    }

    plz help me to get the code



    thank u for ur help in advance




    }







    }

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So what have you done so far?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-22-2008, 12:19 AM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 02:04 PM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 05:14 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05:10 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21