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

  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-21-2008, 11:19 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

Tags for this Thread