c++学习4 -- 输入输出
生活随笔
收集整理的這篇文章主要介紹了
c++学习4 -- 输入输出
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
cout 輸出
#include <iostream> using namespace std;int main() {cout << "hello c++" << ' ' << 12; //可以連續輸出cout << 'a' << 12.123 << endl;//自動識別類型int a = 12;char b = 'b';float f = 123.12f;cout << a << b << f;system("pause");return 0; }?
endl 換行符
#include <iostream> using namespace std;int main() {cout << "hello c++" << endl; //換行,并且清空緩沖區 cout << "hello c++" << '\n'; // \n 換行符 system("pause");return 0; }// endl 多了一個刷新緩沖區的操作,這個操作,會使緩沖的字符立刻顯示在屏幕上。 // \n 則不保證這一點,也就是說在一些操作系統上,\n的顯示會慢一點,常用的這些系統不會遮掩不過,與endl沒什么區別 // 比如鍵盤輸入的字符,?
cin 輸入
#include <iostream> using namespace std;int main() {char c;int a;double d;cin >> c;cout << c;cin >> c >> a >> d;cout << c << ' ' << a << ' ' << d << endl;system("pause");return 0; }?
轉載于:https://www.cnblogs.com/mohu/p/8953452.html
總結
以上是生活随笔為你收集整理的c++学习4 -- 输入输出的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IPC 之 Binder 初识
- 下一篇: Java 并发编程——Executor框