G
Guest
Can anyone tell me why this statement doesn't work?
for (int at=0;at==-1;at=msg.IndexOf("\n",at+1)) n++;
All I'm trying to do is count the number of newlines in a string.
When I step through it in the debugger, it highlights the first statement
(int at=0),
then highlights the second statement, then jumps to the next line of code.
It doesn't appear to increment n at all, nor does it appear to ever evaluate
the 3rd statement of the for loop. The string I debugged with has 3 newlines
at various locations.
Thanks,
Gary
for (int at=0;at==-1;at=msg.IndexOf("\n",at+1)) n++;
All I'm trying to do is count the number of newlines in a string.
When I step through it in the debugger, it highlights the first statement
(int at=0),
then highlights the second statement, then jumps to the next line of code.
It doesn't appear to increment n at all, nor does it appear to ever evaluate
the 3rd statement of the for loop. The string I debugged with has 3 newlines
at various locations.
Thanks,
Gary