02.03.2013, 08:34
There's nothing wrong with the if statement - he is simply escaping the ' character to avoid problems with the compiler detecting it as the end of the string.
if(inputtext[i] == '\'')
... is a perfectly valid check.
By the way, your loop could use some improving instead. Your current code will call strlen() n times where n = strlen(string). This can be reduced to 1 only. The longer your string gets, the more time these strlen() calls will consume.
// Edit: try out inputtext[i] == 27 for the sake of it
if(inputtext[i] == '\'')
... is a perfectly valid check.
By the way, your loop could use some improving instead. Your current code will call strlen() n times where n = strlen(string). This can be reduced to 1 only. The longer your string gets, the more time these strlen() calls will consume.
// Edit: try out inputtext[i] == 27 for the sake of it