方法一:
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#define PRICE 30; /*定义一个符号常量*/
int _tmain(int argc, _TCHAR* argv[])
{
int num, total;
num = 10;
total = num * PRICE;
printf("total %d\n",total);
fflush(stdin); /*清空输入缓冲区,通常是为了确保不影响后面的数据读取(例如在读完一个字符串后紧接着又要读取一个字符,此时应该先执行fflush(stdin);)。*/
getchar(); //用于暂停程序
return 0;
}
方法二:
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
//#include "stdio.h"
//#include "math.h"
#include "windows.h"
#define PRICE 30; /*定义一个符号常量*/
int _tmain(int argc, _TCHAR* argv[])
{
int num, total;
num = 10;
total = num * PRICE;
printf("total %d\n",total);
system("pause"); //通过system函数调用cmd命令
return 0;
}
二〇一四年九月二十八日 14:31:52
评论区