I am having a hard time with this excercise. Can anyone give me a suggestion?
thanks
I am having a hard time with this excercise. Can anyone give me a suggestion?
thanks
I know how to do it now
chucked this together, not everything is declared but should give you an idea how to do it..
Code:int i = 0; int numAppearances = 0; while (string[i] != '\0') { int j = 0; while (j < substringLength) { if (string[i++] == substring[j++]) { if (j == substringLength) { numAppearances++; } } else { break; } } }
Last edited by space-oddity; 05-01-2008 at 04:33 AM.
Or just strstr()... or strcmp(). Why are people scared of pointers!?
Why bother with some thing that the standard library supplies?
Last edited by zacs7; 05-01-2008 at 06:01 AM.
Practice is derived from practical,
It's practical to use the standard C functions. Hence, you practice practicallity.
It's less code, and teaches you more IMO. If it's an assignment, which it appears to be -- unless otherwise stated it'd be a waste of time to reinvent the wheel.