Thread: Fstream. I/O

  1. #1

    Fstream. I/O

    Hello, i am having some trouble with Fstream. I did not study fstream but im studying now.

    Since im making a 2d Engine in sdl, I'm trying to find out how the files will actually load...i have found out's how i will do it.

    Let's say for music.

    I write to a Music.txt file.
    Then, i write the number "MusicLocation"

    let's say...

    1 "Music.mp3"
    2 "Music.mp3"

    Now, fstream will read the numbers and save them into the music array, then i will make Sdl load all the musics from this array. The sdl part, im doing it myself, it's easy...but i'm really not comfortable with fstream.

    If i can get any help from you, that'll be a pleasure.

    I need fstream to read the number and the location. The number will save into the array.

    1 "Music1.mp3" <-- This music will save into Music[1] Actually, "Music1.mp3" will save into Music[1] not the number.But the number tells Music1.mp3 where to save. I need a find function.
    2 "Music2.mp3" <-- This music will save into Music[2]

    Thank you.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    If you're not comfortable with C++ file streams, you probably are not ready to write a 2D game engine.

    Either way, you need a way to know how to load all your music files. What you could do is have an ini or xml file that lists all of the music files and what order they should be loaded in. Otherwise, you'll have to scan the entire directory and parse the names yourself, and that is not a portable option in the C++ standard library.

  3. #3
    Yes, i am ready to write one, i am writing one currently and stuff are working great... i just need to know how fstream works. Then, i could make the good stuff, such as Tile map editor,...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fstream file I/O, getting keystrokes
    By mcborn in forum C++ Programming
    Replies: 1
    Last Post: 03-24-2008, 01:04 AM
  2. I/O with strings
    By kristentx in forum C++ Programming
    Replies: 1
    Last Post: 09-13-2007, 02:18 AM
  3. ARGH! fstream errors
    By OttoDestruct in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2004, 10:37 PM
  4. Overlapped I/O and Completion Port :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 10-30-2002, 05:14 PM
  5. I/O Problems - fstream
    By mol in forum C++ Programming
    Replies: 17
    Last Post: 10-16-2001, 03:50 PM