循环时GCC错误无限

时间:2015-11-23 02:42:36

标签: c while-loop infinite-loop

$ curl -I http://techslides.com/demos/sample-videos/small.mp4
HTTP/1.1 200 OK
Server: nginx/1.4.1 (Ubuntu)
Date: Mon, 23 Nov 2015 04:25:36 GMT
Content-Type: video/mp4
Content-Length: 383631
Last-Modified: Sun, 16 Feb 2014 18:49:36 GMT
Connection: keep-alive
ETag: "53010840-5da8f"
Accept-Ranges: bytes

当我在OSX上的C程序中使用#include <stdio.h> int number, total; int main (void) { total = 0; while (true) { printf ("Enter a number (-1 to stop)\n"); scanf (" %d", &number); if (number < 0) { break; } total = number + total; } printf ("The total is %d", total); return 0; } 循环时,出现以下错误

while (true)

然而,当我在我的Windows分区(通过GCC程序)上运行它时,我没有收到错误..

这是对osx的GCC限制吗?

1 个答案:

答案 0 :(得分:2)

将以下内容添加到文件顶部:

#include <stdbool.h>

这将定义booltruefalse