首页 > 其他 > 详细

cout和printf

时间:2015-12-21 01:55:28      阅读:143      评论:0      收藏:0      [点我收藏+]
#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流的操作顺序是:

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

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

cout和printf

原文:http://www.cnblogs.com/donald1024/p/5062301.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!