C语言的简单问题,哪里错了?

来源:百度知道 编辑:UC知道 时间:2024/09/28 13:03:54
#include<stdio.h>
main()
{char str[100];
scanf("%s",str);
{int i=0;
while(!str[i])
{if(str[i]=='d')
printf("yes");return;}
i++;}
printf("no");
}

#include<stdio.h>
int main(void)
{
char str[100];
int i=0;
scanf("%s",str);
while(str[i])
{
if(str[i]=='d')
{
printf("yes");return ;
}
else i++;
}
printf("no");
return ;
}
1.C语言中所有的变量声明定义都必须在程序开头.
2.大括号没有对应.
3.return是返回一个值,但是主函数并没有定义返回类型.
4.while的用法.
建议楼主打好基础.

楼上的,你的答案也运行不出答案啊!

scanf("%s",str);

不需要&号的吗?