Create and run Kernighan and Ritchie's famous "hello, world" program:
创建并运行Kernighan和Ritchie的著名的“hello, world”程序
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
}
Do you get a warning message from the compiler? If so, what's needed to make it
go away?
你是否收到编译器的警告信息?如果是的话,需要做什么才能让它消失?
Compiling the program produced no errors using gcc version 7.2.0. Here is the
complete output of run commands:
使用gcc版本7.2.0编译程序时没有出现错误。以下是运行命令的完整输出:
$ gcc 1.c -o 1 -Wall -W -pedantic -std=c99
(no output, no warnings or errors)
$ gcc 1.c -o 1 -Wall -W -pedantic -std=c89
1.c: in function 'main':
1.c:5:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
This warning can be fixed by amending return 0;
to the program (see 1b.c
):
这个警告可以通过修改程序中的 return 0;
来解决(参见 1b.c
)
$ gcc 1b.c -o 1b -Wall -W -pedantic -std=c89
(no output, no warnings or errors)