This is really weird...
My program is doing something funky...something that is contrary to what my code says (I know you wont believe this, but if you continue to read, I'll explain).
For example (this is an abbreviated version of my code):
Both of these if statements are in a do-while loop, with the code in the same order I posted it. Here is what the relevant output is:Code:if (!obj.atEndOfFile()) { cout<< "Not yet at end of file." <<endl; script_found = obj.findScriptTag(storage_str1); cout<< "script_found: " << script_found <<endl; } if (script_found == false) { cerr<< "Error! File did not contain any Javascripts!\n" "Please pass a file with a javascript in it!\n\n" "Exiting out..."; return 1; }
The two bolded lines are what I'm talking about. The returned value of the obj.findScriptTag() function is absolutely true (I checked this by outputting "Function is about to return true." right before the "return true" statement inside the findScriptTag() function, and as you can see from my quoted output above, this statement was outputted. Now, if you look closer at the above code, you'll see that in the topmost if statement, which is entered if input_stream is not at end of file, there is only ONE output statement (as the last statement of that block of code) for the value of "script_found" which is the name of a bool variable given the initial value of false when I defined it right before entering the do-while loop, while in the output, on the other hand, it shows it outputted two DIFFERENT values of that variable along with the text "script_found: " in front of it.Function is about to return true.
script_found: 1
Not yet at end of file.
script_found: 0
Error! File did not contain any Javascripts!
Please pass a file with a javascript in it!
So, to summarize, in short, its outputting the original (correct) value of "script_found", though it is bizarrely before the output statement "Not yet at end of file." which is actually BEFORE it in the code, then its outputting the statement I just mentioned, and then the same statement with "script_found" again, only this time the value of script_found is 0 instead of 1. And it is clear that that's what the end value of "script_found" must be (even though the function of which return value was assigned to that variable): false, seeing as the if statement which checks that value is entered.
Now can anyone explain why the output is different than what the code is telling it to do?
BTW, I tried manually deleting the .obj files of the program, so they would be created again, thinking that maybe it was using prior code, but it still does the same thing. If you need any more details, just ask.