Why my program isn't accepting the second input?

Solution 1:

Since char can only hold a single character, you may use std::string for storing names.

Example:

#include <iostream>
#include <string>


int main( )
{
    std::cout << "Enter your first name\n";
    std::string firstName;
    std::getline( std::cin, firstName );

    std::cout << "Enter your last name\n";
    std::string lastName;
    std::getline( std::cin, lastName );

    std::cout << "\nHi " << firstName << ' ' << lastName << '\n';
}

Sample input/output:

Enter your first name
John
Enter your last name
Connor

Hi John Connor