Using inFile to read from TXT yields gibberish
Hello. I'm using the following code to try to just read a few names from a text file (I'm learning C++ from a college book). However, when I run it, the outputFile program makes the names right, but when I read it in, I get gibberish.. like ASCII characters.
I've tried re-starting the computer, and making sure NOTEPAD was the default .TXT document program.
Thanks for any help.
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
ifstream inFile;
const int SIZE = 81; //Size limit
char name[SIZE];
inFile.open("demofile.txt");
cout << "Reading data from the file.\n\n";
inFile >> name;
cout << name << endl;
inFile >> name;
cout << name << endl;
inFile >> name;
cout << name << endl;
inFile >> name;
cout << name << endl;
inFile.close();
cout << "\nDone.\n";
system("PAUSE");
return EXIT_SUCCESS;
}