后面跟着:“Press any key to continue”是很正常的,这是系统自动加上去的,不影响程序的运行,窗口很快消失你只需在主函数最后加上语句getch();就可以了,使用这个函数要包含头文件#include
#include
#include
void main()
{
printf("Hello World!\n");
getch();
}
自己试试吧!
你这个最简单的代码存在点小问题,我想是你马虎打错了。
将printf("Hello World!"\n); 改为printf("Hello World!\n");
两个方法:
方法1.
包含头文件:#include
使用函数:getch();
改过以后:
#include
#include
void main()
{
printf("Hello World!"\n);
getch();
}
方法1.
包含头文件:#include
使用函数:system("pause");
改过以后:
#include
#include
void main()
{
printf("Hello World!"\n);
system("pause");
}
试试吧:)
那是因为程序已经运行完了,所以窗口自动关闭,
只要在程序末加上个getch()就行了,当按下任意键后,窗口会自动关闭。
呵呵我是定义了一个变量,接着获得输入的值。
#include
void main()
{
printf("Hello World!"\n);
int i;
scanf("%d",&i);
}