fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. cout << "Enter your first name: ";
  9. char fname[20];
  10. cin.getline(fname, 20);
  11. cout << "Enter your last name: ";
  12. char lname[20];
  13. cin.getline(lname, 20);
  14. char fullname[40];
  15. strcat(lname, ", ");
  16. strcpy(fullname, lname);
  17. strcat(fullname, fname);
  18. cout << "Here is the information in a single string: " << fullname << endl;
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 2728KB
stdin
George
WasHere
stdout
Enter your first name: Enter your last name: Here is the information in a single string: WasHere, George