Thread: input/output files question

  1. #1
    Registered User
    Join Date
    Nov 2001

    input/output files question

    in for school our last program program 7 he gave us a sequential file.

    so im trying to figure out in all of this how do i print a piece of data(could be string,double,int whatever) from the file out on the screen or at least see if im heading the right direction or not?

    IO::StreamReader *infile;
    IO::StreamWriter *outfile;
    infile = IO::File::OpenText("prgv-7.dat");
    infile->ReadLine( );
    outfile->WriteLine("YAY IM WRITING TO A FILE");
    infile->Close( );
    i suppose the part that REALLY gets me is how do i tell what is what when reading a file like how do i tell this is a number or a String. cause what i wrote up there should read from the file right? and the i could write to the file with writeline that part makes sense but having a hard time grasping telling the difference between the data types then putting them on screen for display?

    (will try and catch teacher at office tommorrow but would be good if i wasnt as lost as i am now. it seemed to make sense in class but went braindead at home) lol

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    It's up to the reader to decide what to do with what you read. If you read the value 0x41 you could either treat it as the character 'A' or as the decimal value 65 which could be an age, a distance or the number of collected items in a game savefile.

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Nov 2001
    so i pretty much determine if its a string/int or whatever and i read it out of the file?

    i just looked at the .dat file again and noticed the 6 pieces of data are written in the same order over and over so essentially all i need to do is read it 6 times in 6 different array string variables? though i think he wants us to use different variable types. cause at the end i have to say which cost the most.

    and print it out that way? i assume thatd work?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about reading from files
    By green11420 in forum C++ Programming
    Replies: 12
    Last Post: 04-22-2008, 11:02 AM
  2. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  3. a question files
    By amin1982 in forum C++ Programming
    Replies: 4
    Last Post: 04-06-2005, 06:10 AM
  4. Question about ".o" files
    By Jez_Master in forum C++ Programming
    Replies: 1
    Last Post: 04-11-2002, 01:54 AM
  5. input/output + Object Files ?
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 12-17-2001, 09:32 AM