Hi, I want to do a function that reads info from a txt file writed in one column that haves a termination string that is "/". I want this "/" to be the end of the loop but I'm only creating an infinite loop or something, and I can't understand why... Please, can you help me?
The thing is I'm unable to do it, cause windows gives an error when I execute the .exe file.
Nothing apears in the console but the console cursor and the error message from windows.
I tried to change it by not using getline() putting a "_" instead of white space in the txt file and I obtain the same result.
Are you testing to see that the file opened correctly?
Did you run the program with you debugger? The debugger will be able to tell you exactly where it detects the problem and you can view the variables at the time of the crash.
If your file fails to open you need you need to stop the program, not just print an error message.
If your strings have spaces embedded within them you can't use the extraction operator>> since it stops processing strings when it encounters whitespace characters.
I know, but I changed the txt file so now it not contains white spaces, instead it have "_" between words.
I did that because you suggested me that the problem could be mixing >> and getline.