How to read a blank character input stream it?
In the standard flow, there is a skipws tag, the default is set, indicating that when the blank character reading, they will be discarded. Use std :: noskipws manipulator can clear this flag:
cin >> std::noskipws;
A case:
#include <iostream>
#include <sstream>
int main()
{
char a, b, c;
std::istringstream iss(" 123");
iss >> std::skipws >> a >> b >> c; // 忽略掉前面的空白字符,PS: 默认std::skipws是置位的
std::cout << a << b << c << std::endl; // 123
iss.seekg(0);
iss >> std::noskipws >> a >> b >> c; // 不忽略空白字符,将其读取
std::cout << a << b << c << std::endl; // ..1
return 0;
}
Reference: http://www.cplusplus.com/reference/ios/noskipws/
---------------------
Author: Demon90s
Source: CNBLOGS
Original: https://www.cnblogs.com/demon90s/p/7704502.html
Disclaimer: This article author original article, reproduced, please attach Bowen link!