若此时进行的操作是编译(F5),可先运行程序(Ctrl+F5),若仍然一闪而过,用下面方法解决。
解决方法如下:
方法一:
1.若是C++文件,在程序最后写一句(return之前)添加:system("pause");
2.若是C文件,首先在程序头添加头文件:#include"stdlib.h";然后在程序最后写一句(return之前)添加:system("pause")。
方法二:
1.右键单击当前工程-属性
2.选择配置属性-链接器-系统
3.更改系统选项中的“子系统”配置,选择下拉菜单的第一个“控制台 (/SUBSYSTEM:CONSOLE)”
然后选择"开始执行(不调试)",也就是ctrl+F5;
#include "string.h"
#include "stdlib.h" / 为了解决在 CMD 命令中 屏幕显示就退出:system("pause");
#define DENSITY 62.4 ///人的密度
int main()
{
float weight, volume;
int size, letters;
char name[40]; name 是一个有40个字符的数组
printf("Hi! What's your first name?\n");
scanf("%s" ,name);
size = sizeof name;
printf("Hi! What's your weight in pounds?\n");
scanf("%f" ,&weight);
letters= strlen(name);
volume=weight/DENSITY;
printf("Well, %s your volume is %2.2f cubic feet.t\n", name, volume);
printf("Also, your fisrt name has %d letterss,\n", letters);
printf("and, we have %d btyes to stroe it in.\n", name,size);
system("pause");
return 0;
}