Hello,
I started learning C++ yesterday and have been working through the tutorials. I have come to the part regarding File I/O and am a little stuck...
The above is a snippet from my code, the problem is cout'ing old_ans only outputs the first word from the file, how should i go about outputting the whole file contents?Code:ifstream ifile("test.txt"); ifile >> old_ans; ifile.close(); cout << "File contents:\n\n" << old_ans;
My previous experience is with PHP in which i would just use:
But being a c++ newbie i am a little stuck on a simple problem.Code:$var = file_get_contents('text.txt'); etc
Thank you for any help or advice you can give me.