#include <stdio.h>
main(void){     printf("\n***********");
 for(int a=1 ; a <= 8 ; ++a)
  printf("\n* *");
 printf("\n***********\n");
         getchar();
}帮忙看看出了什么问题

解决方案 »

  1.   

    楼主是问for循环的次数问题?
      

  2.   

    不是的  你看.....  写成这样
                 #include <stdio.h>
    main(void){
           
          int a;
         printf("\n***********");
     
         for(a=1 ; a <= 8 ; ++a)
          printf("\n*         *");
          printf("\n***********\n");
          getchar();}
    就可以执行了  不然前面的代码就老提示错误
      

  3.   

    没看出什么错误?除了你的main函数写的不规范以外,
    你前面的代码提示什么错误信息?
      

  4.   

    error C2143: syntax error : missing ';' before 'type'
     error C2143: syntax error : missing ';' before 'type'
     error C2143: syntax error : missing ')' before 'type'
     error C2143: syntax error : missing ';' before 'type'
     error C2065: 'a' : undeclared identifier
     warning C4552: '<=' : operator has no effect; expected operator with side-effect
     : error C2059: syntax error : ')'
     : error C2146: syntax error : missing ';' before identifier 'printf'
      

  5.   

    你的文件后缀应该是.c  用的应该是trubo c的编译器,那么变量的定义就不能放在for循环里面局部定义而应该在第一个执行语句之前
      

  6.   

    c++支持for(int i = 1;.....)或者 int i; for(i=1;.....) c++是c的超集
    c 支持 int i; for(i=1;.....)从编译器上来说(vc) 源文件 后缀为.c支持 int i; for(i=1;.....)
      源文件后缀名是.cpp 两者都可以所以lz的源文件后缀是.c的,按c的写法就可以了,没错误,不用怀疑。
      

  7.   

    我在vc6.0下运行都可以不知道你是为什么,估计是直接用命令编译的,注意编译时有版本的,for(a=1 ; a <= 8 ; ++a)编译要通过需要添加编译控制选项-std=c99