reading file delim

This is a discussion on reading file delim within the C Programming forums, part of the General Programming Boards category; how do u deliminate files properly when writing so u can read them back in to the arrays they came ...

  1. #1
    Unregistered
    Guest

    Question reading file delim

    how do u deliminate files properly when writing so u can read them back in to the arrays they came from later.

    my attemps so far have resulted in very joined up fields

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    character, integer, float point array or what?
    Last edited by no-one; 03-05-2002 at 11:59 PM.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    are you trying to deliminate files or tokenize a string in the program itself? If you're looking at the former, I find that the colon (:) makes a good delimiter. If you're trying to figure out the latter, post some code.

    starX
    www.axisoftime.com

  4. #4
    Unregistered
    Guest
    im tring to write an array of a structure that contains strings and floats and ints.

  5. #5
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    well there are two plausible ways of doing this if your writing chunks of mixed data to a file,

    1. everything has a predetermined size

    this is good for pure data structures where you know what the exact size will always be,
    the down side is you have limited space for strings that must always be written

    2. Write the size of the struct in bytes to the file

    write the size of the struct preceeding it in the file and read the size in, and then read the appropriate number of bytes stated by that size.

    rinse and repeat!
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 02:04 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 01:36 PM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM

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