questions on reading file in c++

This is a discussion on questions on reading file in c++ within the C++ Programming forums, part of the General Programming Boards category; hi I was in the middle of doing my program in c++ and suddenly i had the urge to do ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    61

    questions on reading file in c++

    hi I was in the middle of doing my program
    in c++
    and suddenly i had the urge to do some file reading to it
    my question is
    can i use another function outside the main to open the file for reading starting with the opening commands
    is this possible
    can you show me some examples
    because if i read the file the main
    the coding will become much of a mess.
    please help answer my doubts

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,717
    Quote Originally Posted by MyRedz
    can i use another function outside the main to open the file for reading starting with the opening commands
    Yes.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    61
    ok.
    another question
    can i do two structs aka data structures
    in 1 c++ code program??
    i mean 1 to read and 1 to open and write and save???

  4. #4
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Yeah, why not?
    The best would be to create one struct/class with functions to read, write and save.

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    61
    but the files are different
    one file is only to read
    and another is to read write and maybe save
    can you show some examples please

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, 01:04 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM

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