求帮忙看一下这个c语言程序哪有问题

题目要求:在不能使用已有字符串库函数条件下,返求出从字符串str中sFind子字符串出现的次数,如果str中不包含sFind则结果为0。

我编的:
#include<stdio.h>
#include<math.h>
int main()
{
int a = 0, b, c = 0, d = 0;
char str[32], sFind[32];
int i, j,k;
printf("please put str\n");
gets(str);
printf("please put sFind\n");
gets(sFind);
for (b = 0; b < 32; b++)
{
a = 0;
if (str[b] == sFind[a])
{
c = b;
while (sFind[a] == str[c])
{
if (sFind[a] == '\0')
{
d = d + 1;
break;
}
a = a + 1;
c = c + 1;
}
}

}
printf("%d", d);
return 0;
}

程序可以执行但的不到想要的结果0.0

还有一个问题,我用F10调试的时候不小心把哪个窗口关了,本来应该每点一下F10就显示一下各个变量的值现在那个窗口没了,应该在视图选项里把哪个重新打开一下?

#include<stdio.h>
#include<math.h>
int main()
{
int a = 0, b,d = 0;
char str[32],  sFind[32];
int i, j,k;
printf("please put str\n");
gets(str);
printf("please put sFind\n");
gets(sFind);
for (b = 0; str[b]; b++)
{
a = 0;
if (str[b] == sFind[a])
{
while (sFind[a] == str[b])
{
a = a + 1;
b = b + 1;
if (sFind[a] == '\0')
break;
}

if (sFind[a] == '\0')
{
d = d + 1;
}
b=b-1;
}
}
printf("%d\n", d);
return 0;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2016-05-20
for (b = 0;str[b]!='\0'; b++)
{
a = 0;
if (str[b] == sFind[a])
{
c = b;
while (sFind[a]!='\0')
{
if (sFind[a]!=str[c])
{
break;
}
a = a + 1;
c = c + 1;
}
if(c-b==a)
d=d+1;
}

}


alt+3可以重新打开视图窗口

追问

alt+3没反应0.0

本回答被提问者采纳
相似回答