Skip to content

Instantly share code, notes, and snippets.

@2hanX
Created June 16, 2020 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2hanX/73fcea2a16a2db01eca0e9397f8c5d53 to your computer and use it in GitHub Desktop.
Save 2hanX/73fcea2a16a2db01eca0e9397f8c5d53 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<cstring>
using namespace std;
struct person
{
char fname[10];
char lname[10];
};
int main()
{
person p;
char name[20];
cout << "Enter your first name: ";
cin.getline(p.fname,10);
cout << "Enter your last name: ";
cin.getline(p.lname, 10);
strcpy_s(name, p.lname);
strcat_s(name, ", ");
strcat_s(name, p.fname);
cout << "Here's the information in a single string: " << name << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment