【发布时间】:2014-06-26 01:55:35
【问题描述】:
我正在努力让 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");
}
【问题讨论】:
-
in "char #;" # 是保留关键字。给一个不同的变量名。
-
行 printf ("%c = tower_height - 2\n");也搞砸了。您可能想要打印一个 int (%d) 并需要在字符串之后提供它。
-
你在做什么??
-
这个问题可以移到CS50部分吗?它可能在那里最有用。
-
另外,最好不要先使用循环就开始学习。从 C 中的关键字、变量命名约定、使用分号和类型括号等开始。获取一本好的手册,一次从一个开始。万事如意!