//写给正在学习VC++8.0的朋友们,或许没有什么帮助,但是这是在学习中所遇到的一些问题.
//代码在vs2005中运行通过.
#include "stdafx.h"
#include <IOstream>
#include <iomanip>
using namespace std;
int sample()
{
int i;
i=10;
int j;
j=15;
return i*j;
}
int _tmain(int argc, _TCHAR* argv[])
{
int num1=23;
int num2=56;
int c;
cout<<"使用默认输出格式:"<<endl;
cout<<num1<<num2;
cout<<endl;
cout<<"使用Setw输出格式:"<<endl;
cout<<setw(6)<<num1<<setw(6)<<num2;
cout<<endl;
cout<<"使用函数时不注意细节从而得到两种不同的结果"<<endl;
cout<<"cout<<sample得到的结果:"<<sample<<endl; //错误的使用方法
cout<<"cout<<sample()得到的结果:"<<sample()<<endl;//正确的使用方法
cin>>c;
return 0;
}
运行后的结果大家可以看一下有什么不同,体会一下.