I think the code would be broken by the (mis)placement of {}-brackets. The logic looks sound to me. The atoi function converts a string to integer, and if that integer is greater than zero, then jump(i) begins to happen.
The validity of the strcmp call depends on your programming language. I think in C/C++ you would want the '!' for a logic inversion but in Matlab strcmp returns the index of where 'jump' is located within words, so in Matlab that if-statement would be OK as-is (although Matlab likes single quotes for strings).
Haley,
ReplyDeleteAre you sure it is not supposed to read
if(!(strcmp(words, "jump))
?
That would mean if the words equals jump, then you print how high. But then you call the function jump with an uninitialized "i"!!
/narayan
+1 to narayan's comments :P The code doesn't work.
ReplyDeletecyn
I must have reproduced it incorrectly. See how smart you guys are? :-)
ReplyDeleteI think the code would be broken by the (mis)placement of {}-brackets. The logic looks sound to me. The atoi function converts a string to integer, and if that integer is greater than zero, then jump(i) begins to happen.
ReplyDeleteThe validity of the strcmp call depends on your programming language. I think in C/C++ you would want the '!' for a logic inversion but in Matlab strcmp returns the index of where 'jump' is located within words, so in Matlab that if-statement would be OK as-is (although Matlab likes single quotes for strings).