C++ 文件IO get()

 1 #include <iostream>
 2 using namespace std;
 3 int main(int argc, char *argv[])
 4 {
 5     cout << "请输入两个字符:" << endl;
 6     
 7     //第一个字符 
 8     cout << cin.get() << endl;
 9     
10     //第二个字符 
11     cout << (char)cin.get() << endl;
12     
13     //第三个字符 
14     char ch;
15     cin.get(ch);
16     cout << ch << endl;
17     return 0;
18 }

读取文件,一秒钟显示文件中的一个字符。

 1 #include <iostream>
 2 using namespace std;
 3 #include <fstream> 
 4 #include <ctime>
 5 int main(int argc, char *argv[])
 6 {
 7     ifstream fin("D:\a.txt");
 8     char ch;
 9     while(fin.get(ch))
10     {
11         cout << ch << flush;
12         time_t t = time(NULL);
13         while(t == time(NULL));
14     }
15     return 0;
16 }
原文地址:https://www.cnblogs.com/autumoonchina/p/3641805.html