cout和printf

#include <iostream>
using namespace std;
int main()
{
    int i=0,j=0;
    cout<<i++<<"\t"<<i++<<"\t";
    cout<<i++<<endl;
    printf("j++\tj++\t");
    printf("j++\n");
    return 0;
}

VC6.0

 

 

#include <iostream>
using namespace std;
int hello1();
int hello2();
int main() 
{
    int a, b;
    cout<<"a="<<hello1()<<" b="<<hello2()<<endl;
    printf("a=%d    b=%d\n",hello1(),hello2());
    return 0;}
int hello1()
{
    cout<<"hello1"<<endl;
    return 1;
}
int hello2() 
{
    cout<<"hello2"<<endl;
    return 2;
}

 

VC6.0

cout流的操作顺序是:

先从右往左读入缓冲区,然后再从左往右输出。所以它从右边往左读的时候,碰到了函数当然去执行函数先了,然后把函数返回值读入缓冲区再然后。。。就是从左输出了。

貌似编译器不同结果不同,所以需规范自己的输入输出

posted @ 2015-12-21 00:25  chris_chan1024  阅读(249)  评论(0编辑  收藏  举报