Thread: questions on reading file in c++

  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
    28,413
    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.
    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
    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, 02:53 AM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10: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, 03:58 PM