4/5 输入输出流

1.输入输出三种
1.标准IO
系统指定的标准设备进行输入 输出
2.文件 i/0
以外存磁盘文件为对象进行输入输出
3.串I/0
对内存中指定的空间进行输入输出

image
13: char c = cin.get();
mov esi,esp
mov ecx,dword ptr [__imp_std::cin (06D098h)]
call dword ptr [__imp_std::basic_istream<char,std::char_traits >::get (06D09Ch)] ///缓冲区存值
cmp esi,esp
call __RTC_CheckEsp (06128Ah) //缓冲区取值
mov byte ptr [c],al

image

14: cin.get(c1);
mov esi,esp
lea eax,[c1] //后续直接在get对象函数里面修改了
push eax
mov ecx,dword ptr [__imp_std::cin (049D098h)]
call dword ptr [__imp_std::basic_istream<char,std::char_traits >::get (049D0E0h)] // 读取缓冲区 输入缓冲区 并且缓冲区的值给c1
cmp esi,esp
call __RTC_CheckEsp (049128Ah)

image

image

mov esi,esp
push 0
push 400h
lea eax,[buf]
push eax
mov ecx,dword ptr [__imp_std::cin (0EBD098h)]
call dword ptr [__imp_std::basic_istream<char,std::char_traits >::get (0EBD0E4h)] // 读取缓冲区 输入缓冲区 并且缓冲区的值给c1
cmp esi,esp
call __RTC_CheckEsp (0EB128Ah)

读一行
image

6.忽略
//将缓冲区的第一个字符拿掉
cin.ignore(5);//忽略的字符多少
char c = cin.get();//检测到缓冲区有数据的时候就不会让你再次输入
cout << c << endl;

7.只读不拿
char c = cin.peek();
cout << c << endl;
cout << c << endl;
当你输入缓冲区结束后 开始输出 不会拿走缓冲区数据
8.放回
char c = cin.get();
cout << c << endl;
cin.putback(c);
把c的数据重新压回缓冲区

案例1 判断字符

cout << "输入字符或者数字" << endl;
char c = cin.peek();
if (c >= '0' && c <= '9')
{
int num;
cin >> num;
cout << "输入的数字是" << num << endl;
}
else
{
char buf[1024] = { 0 };
cin >> buf;
cout << "输入的字符串是" << buf << endl;
}
案例2 数字
int num;
while (1)
{
cin >> num;
if (num >= 0 && num <= 10)
{
printf("1");
break;
}
cin.clear();
cin.sync();
这里我们知道
缓冲区 有一个东西存储数据
但是没有看过缓冲区,也懒得进call找 也就这样吧,后续学多了我回在看的

}
posted @ 2023-04-05 23:59  逆向狗  阅读(69)  评论(0)    收藏  举报