diff --git a/mystr_idx b/mystr_idx new file mode 100755 index 0000000..cdfd65f Binary files /dev/null and b/mystr_idx differ diff --git a/mystr_idx.c b/mystr_idx.c new file mode 100644 index 0000000..a3f33d2 --- /dev/null +++ b/mystr_idx.c @@ -0,0 +1,20 @@ +#include +#include +int mystr_idx(char *str, char *substr); +int main(int argc, char **argv) +{ + printf("Print you string\n"); + char s[100]; scanf("%s", s); + printf("Print substring\n"); + char ss[100]; scanf("%s", ss); + printf("Your substr has intex:%d\n", mystr_idx(s, ss)); + return 0; +} +int mystr_idx(char *str, char *substr) +{ + int indx = strstr(str, substr) - str; + if(strstr(str, substr) == NULL) + {indx = -1;} + + return indx; +}