麦伯良 周密:求助关于C++的问题~~

来源:百度文库 编辑:神马品牌网 时间:2024/05/02 09:07:01
我现在用c++写了一个C程序~~
但必须在命令行模式下使用~~
如果直接双击运行后~窗口就不见了....
请问我该怎么办??
例如:
includ<stdio.h>
int d;
scanf("%d",&d);
printf("%d",d);

将上面的程序修改为

#include<stdlib.h>
#include<stdio.h>
void main()
{
int d;
scanf("%d",&d);
printf("%d",d);

system("PAUSE");
}

最后一句是系统调用,能得到和楼上同样的结果。

#include<stdio.h>
void main()
{
int d;
scanf("%d",&d);
printf("%d",d);
printf("%s","press enter to continue");
getchar();
getchar();
}

直接编译
因为输入d后有一个回车,所以多用了一个getchar(),先把这个回车取出来.
而后面的那个getchar(),则是用来取press enter to continue的那个回车

最好可以见到你的程序