this will help One call to operator>> of std::cin reads only up to the first whitespace. When you input 4 words in one line, your std::cin reads the first word, accepts it, and execution continues. But the remaining 3 words are still waiting in the input stream to be read, and they will be read upon next call of operator >>. So, to illustrate what happens, here's an example:
Input stream content: [nothing]
//(type usa americ england gana)
Input stream content: usa americ england gana
//cin >> s;
s == "usa"
Input stream content: americ england gana
//cin >> s;
s == "americ";
Input stream content: england gana
C++ - Overloading operator>> and processing input using C-style strings
By : WestyCHC
Date : March 29 2020, 07:55 AM
will be helpful for those in need So what you basically want is to parse a const char* to retrieve a integer number inside it, and ignore all whitespace(+others?) characters. Remember that characters like '1' or 'M' or even ' ' are just integers, mapped to the ASCII table. So you can easily convert a character from its notation human-readable ('a') to its value in memory. There are plenty of sources on ascii table and chars in C/C++ so i'll let you find it, but you should get the idea. In C/C++, characters are numbers (of type char).