I am new to C++ and I'm having trouble understanding how to import text from a file. I have a .txt file that I am inputting from and I want to put all of the text from that file into a string. To read the text file I am using the following code:
ifstream textFile("information.txt");
Which is just reading a text file name information. I made a string named text and initialized it to "". My problem is with the following code which I am trying to use to put the text from the .txt file onto the string:
while (textFile >> text)
text += textFile;
I am clearly doing something wrong, although I'm not sure what it is.