Today i had a really simple test at school. Read from a file, one line at a time and then search for a particular string in the line. if the string is found output it to a particular file if it is not found to another file. Basically reading from one file and writing to two other files, nothing hard. Now i am used to using linux, nano, terminal and gcc/g++ and kinda that's it. The code is as follows:
It works in linux seamlessly and in MV C++ it fails miserably, mainly because the find function from the string object is not working as the standard description. I will test this code in windows using dev c++, but in linux it works well under QT, eclipse, and terminal. If i know well anyway eclipse uses g++ so only QT has a different compiler if i know well, anyway the thing is it works. Why?
Seems more likely you didn't change the path and the file isn't opening so it loops endlessly on the eof condition.
oh but no, the path was changed to the appropriate location for the desktop, and also i included an escape sequence for every "\" in the windows style path for it to work so the path looks like this:
1 2 3
C:\\Documents and Settings\\student\\Desktop\\student.txt
C:\\Documents and Settings\\student\\Desktop\\info.txt
C:\\Documents and Settings\\student\\Desktop\\altele.txt
So the idea is that i have a problem with the find function, the file opening part works fine. I even cout the string before passing it to the if function in the windows version, just to be sure that they get read in well from the file.
Anyway, you are right, indeed the function is evaluated once more in the loop, and also i have made the update as you suggested, but nonetheless it still doesn't want to work. is there an implementation of find different than the standards? I searched for it but i did not find it. Now i must say i am not an expert in MS C++ so it may be that the ide needs some specific configuration but under the other platform i just simply compile it. Paths are changed and everything... i think i will just need to tokenize the string under MS, that would also be a way but for such a simple program it is like going after a fly with a bazooka...