Reading in from 1 file into 1 dynamic structure

This is a discussion on Reading in from 1 file into 1 dynamic structure within the C Programming forums, part of the General Programming Boards category; Hi everyone, I need the code to reading from a file into a dynamic structure like a list. Any help ...

  1. #1
    ajax
    Guest

    Reading in from 1 file into 1 dynamic structure

    Hi everyone,

    I need the code to reading from a file into a dynamic structure like a list.

    Any help offered is much appreciated.

    Thanks

  2. #2
    Registered User stormbringer's Avatar
    Join Date
    Jul 2002
    Posts
    90
    i suppose you wanna know something about reading from files. have a look at:

    http://www.acm.uiuc.edu/webmonkeys/b...uide/2.12.html

    puting that stuff into the struct depends on the struct. for more information be more specific.

    stormbringer

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    Two ways to go about it.

    First is to read a record, allocate more memory, copy data to new record, repeat until EOF.

    Second is find file size (GetFileSize() or fseek() with ftell() ), allocate memory for whole file, read file and copy data until EOF. If using this method check file size by [ Total_File_Size % sizeof(STRUCT) == 0 ] to ensure good file size.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 02-02-2009, 06:27 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Creating Dynamic Structure in C
    By SomeNath in forum C Programming
    Replies: 1
    Last Post: 03-19-2005, 08:11 AM
  4. Reading a file into a structure array
    By RazielX in forum C Programming
    Replies: 3
    Last Post: 05-02-2004, 09:30 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

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