投入结束时的预期声明或声明?

时间:2013-11-15 03:10:09

标签: c declaration

我感到无聊......并决定进行编码,但尚未完成,但我想知道它为什么不能编译。

/*Coding that will countdown the amount of bottles on the wall
*/
#include<stdio.h>
int main()
{
int bottles = 99;
while (bottles >= 0) {  
put ("%i\n bottles of beer on the wall, %i\n bottles of beer, take one down pass it around", bottles, bottles) ; {
    bottles--; 
    put ("%i\n bottles of beer on the wall", bottles) ;
}
continue; }

2 个答案:

答案 0 :(得分:1)

我不同意答案说你有一个太少的支撑:你也有一个(在put()的最后......改为

/*Coding that will countdown the amount of bottles on the wall
*/
#include<stdio.h>
int main()
{
  int bottles = 99;
  while (bottles > 0) // got rid of '='... Since decrementing inside loop
  {  
    printf ("%i bottles of beer on the wall, %i bottles of beer\n", bottles, bottles);
    printf("Take one down pass it around\n"); // <<<<removed a '}' here...>>>>
    bottles--; 
    printf("%i bottles of beer on the wall\n\n", bottles) ;
  }
  continue; // what is this doing here??? You are not in a while loop...
}

注意 - 我将一个put拆分为两个printf语句,并更改'\n'所在的位置。

答案 1 :(得分:0)

通常,错过括号时会出现此错误。你错过了一个结束的焦点}

#include<stdio.h>
int main()
{
int bottles = 99;
while (bottles >= 0) {  
put ("%i\n bottles of beer on the wall, %i\n bottles of beer, take one down pass it around", bottles, bottles) ; {
    bottles--; 
    put ("%i\n bottles of beer on the wall", bottles) ;
}
continue; 
}
}