im new to c++ so im not sure whats wrong with this but it wont run as it says buffer has not been initailized
std::ifstream file ("c:\\example.txt");
buffer is a pointer, but it is not initialized. That means it could be pointing anywhere in memory, so when you try to read into it that will cause a problem.
If you're new to C++, you probably should be using the C++ string class for strings. What are you trying to read from the file? Is it just text?
from a file. I got that code straight from a book lol. whats the easiest way to read from a file and put that into a variable? what i have there looks easy but obviously doesnt work.
file >> buffer;
But the "best" approach depends on how and what kind of data you want to read.
The above will read a word from the file.
file >> std::noskipws >> buffer;
[Disclaimer: NOT TESTED]
Should read a whole line.
Or you can do
[Unless I mixed up the arguments.]
Anyway, good luck, and avoid pointers (for now).
So what awful book had this exact text?