I hope this isn't a simple answer again, but my work situation doesn't allow me to code the hours i like and as often as I like. The following code emualtes C's STRSTR. however, i noticed it returns only from token[1] and up. Token being the second string argument.
I could do some simple exception handling. But i'd prefer to know why it doesn't return the first address.
Code:
#include <stdio.h>
#define FIND "s"
char *MyStrstr(char *word, char *str);
int main(void){
char *word="superca9038jfcmcdldfjdf";
char *KeyFound = MyStrstr(word,FIND);
if (KeyFound){
puts("found it");
printf("Your looking for \"%s\" ",KeyFound);
}
else
puts("Can't find it");
getchar();
return 0;
}
char *MyStrstr(char *word, char *tok){
while(*word++){
if (*word == *tok)
return word;
}
return NULL;
}