1
0
forked from KIX/lab1_git

func mystr_idx code

This commit is contained in:
KIX
2025-10-18 04:57:40 -04:00
parent 8367bf941a
commit 85275b7f96
2 changed files with 20 additions and 0 deletions

BIN
mystr_idx Executable file

Binary file not shown.

20
mystr_idx.c Normal file
View File

@@ -0,0 +1,20 @@
#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;
}