-
strings
Hello there,
I am trying to write the algorithm for a program that will return 1 (true) if a string argument ends in the substring OH.
I'm pretty confused, even though it seems fairly simple.
Would I accomplish this with an if statement?
something like:
Code:
if string [i] = 'O' && string [i+1] = 'H'
return TRUE;
else return FALSE;
Thanks!
-
Be wary there is no such thing as TRUE and FALSE in C unless you define it yourself. Also your if statement is improperly formed. You should probably look into strstr() and strcmp() for the operation you requested.
-
A regular expression would be the least amount of code to write.
-
you have got it down pat and the next step would be to go from pseudo-code to code.