我在写C语言程序时遇见的问题!

2025-06-27 18:06:59
推荐回答(2个)
回答1:

一看到 hello world! 就知道你学习c语言第一课了,祝贺你进来了。这是正常的,你好打印命令是在一个函数里写的,而随后的return就立即返回了,运行是瞬间的动作,你的眼睛根本反应不过来就结束了。为了能看到,在执行完printf后你应该让程序停一下,给你看到的时间,可以在return前面加个语句,例如,等待让你按任意键再退出,象 getch(); 这样就看到啦。

回答2:

在最上面增加一行#include "stdafx.h"

在return 0;前增加一行system("pause");

程序:

#include "stdafx.h"
#include 
int main(int argc, char *argv[])
{
printf("Hello, world\n");
system("pause");
return 0;
}