include - C++ program sees an included .txt file as code -


I'm just learning the very basic aspects of input / output streams, and my program has not read a text file. This gives me errors which shows that it is trying to read the .txt file as a C ++ code, while I am using values ​​to test my stream.

These are the contents of the included .txt file:

  12345 Success   

And here is the main program code:

  #include & lt; Fstream & gt; # Include & lt; Iostream & gt; # Included "C: \ user \ pawl \ Desktop \ strings.txt" using namespace std; Int main (int nNumberOfArgs, char * pszArgs []) {ifstream in; In.open ("C: \ Users \ Powell \ Desktop \ strings.txt"); Int x; String Sz; & Lt; & Lt; X & LT; & Lt; SZ; In.close (); Return 0; }   

The first error message I received is the "expected unqualified-id numerical constant before", which tells me that the program is trying to compile the included file. How can I stop it and read the text file for the purpose of reading?

code < include your .txt file contains the text for the source code Put in your code in the file, as if you actually pasted it. ifstream . You should not do a file that opens with #include .

Comments