100 degrees, most people will directly understand the Cin::sync () function as a function of emptying the buffer, but if it is on the VS2017 compiler, it will find that the buffer cannot be emptied, why?
Http://en.cppreference.com/w/cpp/io/basic_istream/sync
According to the instructions in this standard document:
The function acts as:synchronizes the input buffer with the associated data source.
Then focus on:
as with Readsome (), it's implementation-defined whether this function does anything with library-supplied streams. The intent is typically for the next read operation to pick up any changes so may has been made to the associated input Sequence after the stream, buffer last filled its get area. To achieve that, could sync()
empty the get area, or it could refill it, or it may does nothing. A notable exception is Visual Studio, where this operation discards the unprocessed input when called with a standard Inpu T stream.
This function is: implementation-defined
So the implementation, can not be able to clear the buffer, the specific implementation with the compiler-related, so do not have a good transplant, use with caution!
Specific information can be referred to the specific description of the site!
Most people in C + + treat Cin::sync () as a misuse of the buffer function