2009-01-29 17:28:09 UTC
#include
#include
int main()
{
using namespace std;
char fname[25];
char lname[25];
char name[53];
cout << "Enter your first name: ";
cin >> fname;
cout << "Enter your last name: ";
cin >> lname;
strcat(name, lname);
strcat(name, ", ");
strcat(name, fname);
cout << "Here's the information in a single string: " << name;
}
I'm new to C++, this is a problem from a book called C++ Primer Plus that asked me to write a program that asks the user to enter his or her first name and then last name, and that then constructs, stores, and displays a third string, consisting of the user's last name followed by a comma, a space, and a first name. Use char arrays and functions from the cstring header.
Not entirely sure where I went wrong. Any tips would be great.