第一个for小括号后面不要分号
你的思路好像完全错了...
#include
#include
#include
int main()
{
char total[80]={0},str[80]={0},temp[80]={0};//80不够的话要加
int i,j;
gets(total);
gets(str);
int len=strlen(str);//求str的字符串长
for(i=0;total[i];++i)
{
if(total[i]==str[0])//首字符限定,减少运算量
{
for(j=0;jtemp[j]=total[i+j];//把total从total[i]开始与str同长度的字符串copy下来,与str比较是否完全相同
if(strcmp(temp,str)==0)break;
}}
printf("%d",i);
system("pause");
return 0;
}
已测试有效。