I want to accept a first and last name separately, and then pass them to a third c-string which will output the full name with a space in between. I wish that strcpy would allow me to copy more than one parameter, but it does not. Which path should I take from here? Thanks.
#include <iostream>
#include <cstring>
usingnamespace std;
int main()
{
char First[25];
char Last[25];
char Full[50];
cout << " Please enter your first name " << endl;
cin >> First;
cout << " Please enter your last name " << endl;
cin >> Last;
strcpy(Full, First); //I wish it would take more parameters here
cout << Full << endl;
return 0;
}
Use std::strings whenever possible. They are much less error prone and much easier to use. There really should be few times where you must use C-strings in a C++ program and there is a member function to convert the string to a C-string if you "must" use a C-string to interface with so external function.