If I understood you correctly, then... there's no one single no-argument function to do it, but there is a way to do it without loops in your code. #include <limits>
// istream ignore
#include <iostream>
#include <limits>
usingnamespace std;
int main () {
char first, last;
cout << "Enter your first and last names: ";
first=cin.get(); //Gets one character from the stream.
cin.ignore(256,' '); //Ignores up to 256 characters, stopping when 256 characters have been found or after a space has been found.
last=cin.get(); //Gets another character from the stream.
cout << "Your initials are " << first << last;
cin.ignore( numeric_limits <streamsize> ::max(), '\n' ); //Pause the console to that you can see what the output is.
//std::numeric_limits <std::streamsize> ::max() is the largest number of characaters that cin can hold.
return 0;
}
I'm sorry but I don't understand all your code. cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
You have write in the comment that this functione pause the console to allow me to see the output, and I've understand this. But how?
What does it mean <streamsize>? And why you use ignore() to pause the console?. I haven't never seen this way to write code.