[RESOLVED] Simply reading txt file - oddly not working
I've tried reading a file several different ways. I get nothing every time. The code seems exactly right.
Read a file >> print the text.
Simple.
I've written similar code.... what am I missing guys?
(I have the text file in the solution dir, and the project dir - pretty sure i just need it in the project dir? but i wasn't sure - c++ AND VS n00b )
I've also tried using a whole pathname to read the text file. I get nothing.
Here's my brilliant code :
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
The above line opens the file test.txt for reading
Code:
in.open("test.txt");
That line attempts to open the file test.txt for reading. Since it
is already open, the statement fails. This sets the streams state
to "bad", so any attempt to read from the stream fails.
The above line opens the file test.txt for reading
Code:
in.open("test.txt");
That line attempts to open the file test.txt for reading. Since it
is already open, the statement fails. This sets the streams state
to "bad", so any attempt to read from the stream fails.
Just remove the open line.
I have removed in.open();
Still no output.... i think it's an error with my getline(); statement
Bookmarks