OK so i have tried to figure out what is wrong with this program i did at least 2 hours of research and couldnt find anything. it is a pretty basic program. I have to retrieve a name and city from a data file and everytime I retrieve the data it only comes up with the first word for the city and name.
here is my program pls help
The extraction operator>> stops processing when it encounters a white space character. If you want to retrieve a string that contains spaces you need to use something like getline(). For more information you will need to provide a small sample of your input file.
I tried using getline() but i didnt know how to use it to output. i used it when to input data into the file and i checked the data file to make sure everything went in right.
That is because you are using the extraction operator>> to retrieve the string. The extraction operator stops when it encounters a white space character. You need to use getline() to extract the string. You don't use getline() for output, this is an input function. You should also not use eof() to control your data entry loop.