C++ Programming help!


Rewrite the program example given. This time, ask the user to enter his first and last names, separated by a space, on one line (i.e., use one “ cin >>” operation to read both the first and last name in one pass). Does a problem occur? If so, describe it in complete sentences. Then try and find a temporary “workaround” to the problem, by any means possible.

// print_string.cpp By Frank Luna


int main( )

std::string firstName = “”;

std::cout << “Enter your first name and press Enter: “;

std::cin >> firstName;

std::cout << std::endl;

std::cout << “Hello, ” << firstName << std::endl << std::endl;

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *