-5

我正在努力让 Char 工作。它不断返回错误。

#include <stdio.h>
#include <cs50.h>
int main (void)

{
int tower_height;
char #;

//                          Inputs        
do {     
    printf("Let's build! Give me a number between 0 and 23 'inclusive'.\n");
    tower_height = GetInt();
}   
while 
    (tower_height < 0 || tower_height > 23); 

//                          Outputs

for (tower_height = 0; tower_height <= 23; tower_height++)
printf ("%c = tower_height - 2\n");

}   
4

3 回答 3

2

C 标识符名称可以包含字母、下划线和数字,只要第一个字符不是数字,并且标识符不是关键字。它们可能不包含#.

于 2014-06-26T02:02:03.140 回答
1

#不是有效的变量名。

于 2014-06-26T01:56:34.997 回答
0

正如所指出的,#不是一个有效的变量名。您可以在代码的第一行看到如何#正确使用:#include <stdio.h>

相反,将您的 char 变量称为使用字母和数字的东西,例如:char c;

于 2014-06-26T02:00:47.040 回答