View Code of Problem 3832

#include<stdio.h>
#include<string.h>
/*
 strstr(str1,str2)
str1: 被查找目标 string expression to search.
str2: 要查找对象 The string expression to find.
返回值:若str2是str1的子串,则返回str2在str1的首次出现的地址;
如果str2不是str1的子串,则返回NULL。
*/
int main(){
	char a[100000],b[100000];
	int d;
	while(gets(a)&&gets(b)){
		d=strstr(a,b)-a;
		if(d>=0){
			printf("%d\n",d+1);
		}
		else
			printf("-1\n");
	}
}

Double click to view unformatted code.


Back to problem 3832