#include <string.h>
#include <stdio.h>
#define buff 255
void main() {
char str1[buff];
char str2[buff];
char *I_str;
printf("STR1=");
gets(str1);
printf("STR2=");
gets(str2);
I_str = strstr(str1, str2);
if (I_str == NULL)
printf("0\n");
else
printf("%d\n", I_str - str1 + 1);
}
Copyright © 2025 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <string.h>
#include <stdio.h>
#define buff 255
void main() {
char str1[buff];
char str2[buff];
char *I_str;
printf("STR1=");
gets(str1);
printf("STR2=");
gets(str2);
I_str = strstr(str1, str2);
if (I_str == NULL)
printf("0\n");
else
printf("%d\n", I_str - str1 + 1);
}