I need some direction on how to split up code into a .h header and two .cpp files.
#include <iostream>
#include <cstring>
using namespace std;
//function for displaying name
void DisplayName(char * Name){
cout<<"Name: "<<Name<<endl; //print name on screen
}
int main(){
char first_name[50]; //static array for holding first name
char middle_name[50]; //static array for holding middle name
char last_name[50]; //static array for holding last name
char choice; //holds user choice
int len; //length of full name
char *name; //holds full name
do{ //loop
cout<<"Please enter last name: "; //prompt for last name
cin>>last_name; //read in last name
cout<<"First name: "; //prompt for first name
cin>>first_name; //read in first name
cout<<"Middle name: "; //prompt for middle name
cin>>middle_name; //read in middle name
//compute length for entire name
len=strlen(first_name)+strlen(middle_name)+strlen(last_name)+3; //3 extra for spaces and terminating null character
name=new char[len]; //allocate memory
if(name==NULL){ //validating allocation
cout<<"Memory allocation error. Terminating."<<endl; //allocation error
break; //terminate loop
} //if
strcpy(name,first_name); //copy first name
strcat(name," "); //append a space
strcat(name,middle_name); //append middle name
strcat(name," "); //append a space
strcat(name,last_name); //append last name
DisplayName(name);//invokes function to display name
delete [] name; //unallocate memory
cout<<"Do you want to enter another name(y/n): "; //ask if he/she want to continue
cin>>choice; //read in choice
while(choice!='y' && choice!='Y' && choice!='n' && choice!='N'){ //validating choice
cout<<"Invalid choice. Please reenter(y/n): "; //invalid choice. ask to reenter
cin>>choice; //read in choice again
} //while
}while(choice=='y'||choice=='Y'); //loop as long as user wants
return 0;
}