Why doesn't my ifstream object work?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ciprian Tomoiag
    New Member
    • Jan 2011
    • 2

    #1

    Why doesn't my ifstream object work?

    Hello. I need to open multiple (text) files one by one and I thought to generate their names and use the streams to read from them.

    Code:
    const char* FIN = FileName.c_str();
    ifstream fin(FIN, ios::in | ios::binary );
    "FileName" is a string (not char[], string) and is generated manually. To read from file I used the extraction operator >> but it just doesn't read. and in the debugger, at the "watch variables" window it says <incomplete type> for the fin object.

    What more should I add?
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    are you sure that the file opens correctly, e.g. using a try {} catch {} structure and printing any message from the catch?

    Comment

    • Ciprian Tomoiag
      New Member
      • Jan 2011
      • 2

      #3
      well, I had a little mistake in generating the filename. I forgot to add the extension. I only generated "file1" and I forgot to append ".txt" to it. Sorry for bothering!

      Comment

      Working...