为什么用Microsoft Visual C++ 6.0写的exe程序脱离运行界面后就不能运行?

来源:百度知道 编辑:UC知道 时间:2024/05/15 03:41:36
比如说我做了一个C程序将它存在桌面上,当我从桌面上点击运行生成的EXE文件时,它只会在屏幕上闪一下就消失了?

在main()中的末尾,retirn 0;之前加上 system("pause");并包含stdlib.h文件即可。示例:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
puts("HELLO");
system("pause");
return 0;
}

因为你编译的是16位控制台程序,可以System("pause"),或getch()等暂停一下。