Once I put a \ in a commented section with //
The program didn't work the way it was suppose to and I couldn't figure out why I was getting funny results and I coudn't see the reason for it. I did spend a lot of time on it and believe it or not, because I had \ in my comment, that part was effecting the output result of the next non-commnted statement.
Here is a proof of concept code. You have to type this exactly as it is. Including the line spacing
int iVar = 0;
// this a test C:\
iVar = 3;
ShowMessage(IntToStr(iVar));
Execute the program, you will get 0 in the message that pops up.
BUT if you type this:
int iVar = 0;
// this a test C:\
iVar = 3;
ShowMessage(IntToStr(iVar));
you will get what you would expect, 3 in the message box. Pay attention to the line spacing between int iVar = 0; and the next line, the commented one.
Imagine the frustration I went through. I was literally frustrated. I spent HUGE amount of time debugging, going step by step, executing line by line to figure out why I was getting funny output.
I realised after I saw the warning produced by the Borland C++ compiler:
Warnning: Continuation character \ found in // comment
I was shocked. Who would expect something like this? A perfect code giving you completely incorrect results? Imagine the pain I went through to catch that! The error being somewhere you are not looking. How can you find an error if you are debugging the wrong section!
The Borland C++ compiler did good over here, obviously the designers knew about this silly thing so they also made a warning about it....
UPDATE: I just tested the code with GNU C++. Guess what, GNU C++ didn't give ANY warning while Borland's bcc32.exe did produce a warning!!
int iVar = 0;
// this a test C:\
iVar = 3;
cout << iVar << endl;
output is 0! but how can it be??? I just said it should be 3! Argh!! Even now I get frustrated lol. This can seriously stuff you up!