Two Files in a Program

This is a discussion on Two Files in a Program within the C++ Programming forums, part of the General Programming Boards category; Hi all, I want to read two files at two different steps in the same program using fstream.can anybody help ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Location
    Qatar
    Posts
    39

    Cool Two Files in a Program

    Hi all,
    I want to read two files at two different steps in the same program using fstream.can anybody help me in this respect.
    Because when i read characters using fstream.It gives me an error of "earlier declaration " of fstream.
    thanxxxxxxx

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Please post (a portion of) your code. It's not particularly hard to have two files open and read from either as needed. You just have to have two different stream variables.

    --
    Mats

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    That sounds like you're doing something like:


    fstream fs;
    // do stuff with it ...

    fstream fs;
    // do more stuff with it


    That's declaring the stream fs twice. What you want to do is fs.open() and fs.close(), I'd imagine.

  4. #4
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Get program to copy itself into program files, then start on startup.
    By guitarist809 in forum Windows Programming
    Replies: 6
    Last Post: 03-03-2008, 09:42 AM
  2. Replies: 5
    Last Post: 02-11-2008, 01:36 AM
  3. Multiple source files for one program
    By gflores in forum C++ Programming
    Replies: 3
    Last Post: 08-15-2004, 03:32 AM
  4. my program wont read my text files in??
    By Neildadon in forum C++ Programming
    Replies: 2
    Last Post: 12-15-2002, 10:08 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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