I want to read each line of text file and store each line into a giant buffer so I can look at all the contents. How would I do this?
int _tmain(int argc, _TCHAR* argv[])
{
ifstream indata; // indata is like cin
indata.open("example.txt"); // opens the file
if(!indata)
{
// file couldn't be opened
cerr << "Error: file could not be opened" << endl;
exit(1);
}
// keep reading until end-of-file
char* buf = new char[50];
char* initContent = new char[350];
while (!indata.eof())
{
indata.getline(buf, 50, '\n');
memcpy(initContent, buf, 50); //I know this isnt right but I just needed to try something
}
indata.close();
cout << "End-of-file reached.." << endl;
return 0;
}