21 lines
457 B
C
21 lines
457 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
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;
|
|
}
|