分享

C与C++输入输出格式比较

 融水公子 2018-08-05
讲解对象:C与C++输入输出格式比较
作者:融水公子 rsgz

向标准输出设备输出:
C++ 
int x=3;
cout<<"x="<<3<<endl;

C
printf("x=%d",x);
---------------------------------------------
向标准输入设备输入:
C++:
int x;
cin>>x;

C:
scanf("%d",&x);
---------------------------------------------
cout结合自运算:
#include<iostream>
using namespace std;
int main(){
    int x(3);
    cout<<x<<" "<<x++<<endl;
    x=3;
    cout<<x<<" "<<++x<<endl;
}

/*
猜猜输出的结果:
提示:cout运算 是从右到左的  就是按照<<方向运算的 
*/
 
 结果:
 

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多