C语言问题,打一个**的框架,按着C语言入门经典上打的,不知道出了什么语法错误,出不来

#include <stdio.h>
int main(void)
{
printf("\n**************");
for(int count=1;count<=8;++count)
printf("\n**");
printf("\n**************\n");
return 0;
}

如果要在vc6.0的.c文件中运行,定义必须在主函数的开始部分,不能跑到某个函数调用之后或执行语句之后 , printf就是一个函数。你的int count=1;在这个函数之后
正确做法如下
#include <stdio.h>
int main(void)
{
int count=1;
printf("\n**************");
for(;count<=8;++count)
printf("\n**");
printf("\n**************\n");
return 0;
}
但是你在.cpp文件中编译运行完全正确追问

我用的是VC6++6.0
而且按你上述的那些打了,右边的框子跑到左边去了,与左边的框子并列了

追答

是这样吗

那我改成下面的你看行吗?

#include <stdio.h>

int main(void)

{

int count=1;

   printf("\n**************");

   for(;count<=8;++count)

   printf("\n*            *");

   printf("\n**************\n");

   return 0; 

}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-11-07
count 定义问题吧,没别的错误啊!
相似回答