I got this code from gametutorials.com, I had to modify it for my complier (its tutorial about file reading #2), sometimes windows will read it, but it will give invalid assignemnt errors most of the time.
Code:
#include <iostream.h>
#include <string.h>
#include <fstream.h>
int main()
{
ifstream file_in("GT.txt");
if(!file_in)
return 1;
char a_word[10];
while(!file_in.eof())
{
file_in >> a_word; // Here we read in a "word"
if (strcmp(a_word,"\n")==0)
cout << "\n";
else
cout << a_word;
cout << " ";
}
file_in.close();
return 0;
}
GT.txt :
This tutorial was brought to by GameTutorials. \n
Testing line 2.