10.\r \n

1.

//2019/03/04
#include<iostream>
using namespace std;
int main()
{
    cout << "abcdefgmn\rhijk";
    system("pause");
    return 0;
}

输出:

2.

#include<iostream>
using namespace std;
int main()
{
    cout << "abcdefgmn\rhijk"<<endl;
    system("pause");
    return 0;
}

输出:

会覆盖前面的值。

3.

//2019/03/04
#include<iostream>
using namespace std;
int main()
{
    cout << "abcdefgmn\rhijk\n";
    system("pause");
    return 0;
}

输出同上:

4.

#include<iostream>
using namespace std;
int main()
{
    cout << "abcdefgmnpp\rhijk";
    cout <<"opq22\rrst\n";
    system("pause");
    return 0;
}

输出:

 

 综上:

\r : 会将指针重新回到句首,在没有遇到endl或者\n的时候不会将缓存显示在控制台上

\n 与endl : endl会刷新缓冲区

 

posted @ 2019-03-04 20:58  虚设经年  阅读(129)  评论(0)    收藏  举报