网游之神级盗贼无防盗:C语言中为什么输出的内容闪一下就没了?

来源:百度文库 编辑:高校问答 时间:2024/05/02 06:50:56
这段
#include<stdio.h>
main()
{
printf("hello");
}

生成.exe后点击 闪一下就没了,看不到输出的内容 威为什么?

在后面加一句getchar()
#include<stdio.h>
main()
{
printf("hello");
getchar();
}

因为tc的运行就是这样的,运行完毕后返回代码页面。
你可以选择菜单里的显示屏幕项显示,或者在代码末尾加上getch();来让程序停止在结尾,这样每次运行程序都会看到结果了。
#include<stdio.h>
main()
{
printf("hello");
getch();
}

在命令提示符下运行。

先运行CMD,然后把文件拖到CMD的窗口,回车!!!

#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("hello");
system("pause");
}

在程序后面加上 getch(); 暂停屏幕