I'm trying to check whether or not the second argument in my program is a substring of the first argument. The problem is that it only work if the substring starts with the same letter of the string.
EDIT: It must be done in C, not C++. Sorry
int main(int argc, char **argv){
if (argc != 3) {
printf ("Usage: check <string one> <string two>\n");
}
int result = my_strstr(argv[1], argv[2]);
if(result == 1){
printf("%s is a substring of %s\n", argv[2], argv[1]);
}
else{
printf("%s is not a substring of %s\n", argv[2], argv[1]);
}
return 0;
}