in C, write a function [char *strmatch(char *str, char *s)]
which will find the first occurance of the string s in the string str and will return a pointer to the first match if such a match occurs. if there is no match, then strmatch() should return NULL
Here is what i came up with. am i close?
char *strmatch(char *str, char *s)
while (char *str != '\0'){
if (*str == *s){
return (*s);
*s++;
}
}
return (NULL);
which will find the first occurance of the string s in the string str and will return a pointer to the first match if such a match occurs. if there is no match, then strmatch() should return NULL
Here is what i came up with. am i close?
char *strmatch(char *str, char *s)
while (char *str != '\0'){
if (*str == *s){
return (*s);
*s++;
}
}
return (NULL);
Comment