Hey guys,
I am supposed to find a substring in a string of characters.Here is my code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int find(char *a, char *key);
int main(void)
{
char string[30];
char substr[10];
char exist;
printf("Enter the string: ");
gets(string);
printf("Enter the substring: ");
gets(substr);
exist = find(string,substr);
if (exist != NULL)
printf("Found that part in original string\n");
else
printf("Have not found that part in original string\n");
return 0;
}
int find(char *a, char *key)
{
while(*a != '\0'){
if(*a == *key)
return (1);
else
return (0);
}
}
Now, it seems to work fine but I get this warning from Borland C++: Function should return a value in function find.
I thought it did return a value which is either a pointer to a substring or a NULL pointer.Ideas?