70,037
社区成员
发帖
与我相关
我的任务
分享
C89
2.1.2.2 Hosted environment
A hosted environment need not be provided, but shall conform to the following specifications if present.
Program startup
The function called at program startup is named main. The implementation declares no prototype for this function. It can be defined with no parameters:
int main(void) { /*...*/ }
or with two parameters (referred to here as argc and argv, though any names may be used, as they are local to the function in which they are declared):
int main(int argc, char *argv[]) { /*...*/ }
#include <stdio.h>
main(){
printf("hello world");
}
该程序的返回结果在不同的操作系统上是不同的,在不遵从C99的编译器上编译其返回结果是随机的,也就是说,当我们使用shell脚本判断该程序执行是否执行成功的时候就会出现问题,当在遵从C99的编译器上编译后,其返回结果是0
./test
if [ $? -eq 0 ]
then
echo "success"
else
echo "failed"
fi
上面这段shell脚本无法正常执行