我刚刚开始学习使用 edX 编写 C 代码,我确信这是一个非常简单的错误,我无法发现。
我得到了一个额外的 ./,我不知道它来自哪里。
这是我得到的输出
How many minutes does your shower last: 3
minutes: 3
bottles: 36./
我在 Cloud 9 上使用 CS50 IDE,我的代码在屏幕截图中感谢您的帮助。
这是我的代码:
int main(void)
{
int showerlength, bottle;
printf("How many minutes does your shower last: ");
scanf("%d", &showerlength);
bottle = (showerlength * 12);
printf("minutes: %d\n",showerlength );
printf("bottles: %d\n",bottle );
}
这是我得到的输出~/workspace/pset1/ $ ./water
How many minutes does your shower last: 3
minutes: 3
bottles: 36./
最佳答案
这看起来不再是一个问题。
我在 CS50 IDE 中测试了完全相同的代码,输出很好。
我什至在有和没有 return(0)
的情况下测试了它在主函数中。它工作正常。
Screenshot
关于c - 意外的 ./用 C 编码时的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41080739/