Thread: a quick file I/O question

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    5

    a quick file I/O question

    hi all

    new C++ program with *SOME* experence

    how do i wright to files and be able to store mutuple varables,like in a .ini file or such

    thats my only questin...

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You might want to read the tutorials that this website offers, including the one on C++ File I/O.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    5
    i looked at that,but it dosent tell me how to store mutuple varables

    it only tells me that itll go into a string of leters numbers and chartars

    what i want to know is how to store MUTUPLE varables and strings in a single file

  4. #4
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by montablac
    what i want to know is how to store MUTUPLE varables and strings in a single file
    This question doesn't make much sense to me. If you know how to output one value there should not be a problem to to the same thing again.
    Show us an example of how your outputfile should look like.
    Kurt

  5. #5
    Information Crocodile
    Join Date
    Dec 2004
    Posts
    204
    So you want an instant code that reads an ini file? is that it?

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    5
    @ Zuk:
    have you ever opened a .ini file,kinda like that

    @ ioko:
    yea,any help on this

  7. #7
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by montablac
    how do i wright to files and be able to store mutuple varables
    Quote Originally Posted by montablac
    ,like in a .ini file or such
    So you want to write to an ini-file but it could be a different format as well.
    Quote Originally Posted by montablac
    i looked at that,but it dosent tell me how to store mutuple varables
    it only tells me that itll go into a string of leters numbers and chartars
    Now I understand you know how to write one value to a file but you don't know how to do it multiple times.
    Quote Originally Posted by montablac
    @ Zuk:
    have you ever opened a .ini file,kinda like that
    Now I know that you actually don't want to write a file.
    It's reading an .ini file what you really want.

    And yes I have done that before. It's very straightforward.
    Code:
    read a line from the file
        if the first non whirspace character is a '[' its a section. cut the '[' and the ']' and you have the name of the section.
        else if  the line contains a '=' the part before the '=' is a variable name the part after the '=' is the value.
           now you just have to check if the value-part is a number or a string
    continue until eof is reached.
    show some code that we can help with actual problems and don't let us guess about your intentions.
    Kurt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File i/o and ASCII question
    By muzihc in forum C Programming
    Replies: 13
    Last Post: 11-04-2008, 11:46 PM
  2. Question regarding File I/O
    By mhenderson in forum C Programming
    Replies: 4
    Last Post: 08-03-2006, 12:46 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. C++ File I/O question
    By zero_cool in forum C++ Programming
    Replies: 3
    Last Post: 08-16-2005, 10:43 AM
  5. File I/O on Network drive, Quick Question
    By kransk in forum C++ Programming
    Replies: 3
    Last Post: 11-24-2003, 09:17 AM