my question is a little bit strange, but how is it possible to read some string from keyboard char by char without using scanf()
and getchar()
only by using operator<<
, for example I want to change every letter a
which I read by *
thanks in advance
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Depending on your purposes, you may find it adequate to do this:
See http://www.cplusplus.com/reference/iostream/manipulators/noskipws/ for further details of noskipws, which is crucial as otherwise operator>> will skip over spaces, tabs and newlines until it finds other characters to put in 'c', resulting in all the aforementioned whitespace characters being removed from your output.
Try writing out to a type of char.
You cannot.
operator <<
uses cooked inputs.However, if you really meant you are looking for a solution using C++ iostreams and not C stdio functions, then use
cin.get()
which is the C++ iostreams equivalent togetchar
.