I think what you want is to append not copy. I'm not sure, but if I remember correctly copy will overwrite any previous value. You could use simply concatenation I believe, like this:
fullName = firstName + " " + lastName;
The reason you are getting the funky output for name though is that you are using fullname[20] as your output. Since you fullName array is declared as having size 20, it has elements from 0 to 19. 20 is outside the array. Also, remember that the array is an array of characters, so trying to output a single element of the array will only display a single character. To output the entire array simply use fullName.
Edit: Actually, <cstring> has a function called strcat that should work for you too.
Note that if you strcat, you must make sure the destination string (fullName) is initialized or you may overstep array bounds.
I recommend first doing a strcpy, followed by strcats:
1 2 3
strcpy(fullName, firstName); // <- strcpy first
strcat(fullName, " "); // <- then strcat
strcat(fullName, lastName);
Of course this is much much easier and safer if you just use strings instead of char arrays... but this looks like a homework problem and I'm assuming you're not allowed to use strings.
I used this code and it crashed after inputting the data, I changed what you told me to, maybe I put it in the wrong order:/
//final review
//====================================================
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
This only gives me the first name, I've tried several variations but I can't get the last name to output. The space outputs as well, but not the lastName array.
Make sure your 'lastName' array actually contains a name and isn't empty.
EDIT: ah, yes... that's the culprit:
1 2 3 4
cin >> age; // using the >> operator leaves the newline in the buffer
cout << "Enter your last name: " << endl;
cin.getline(lastName, 10); // so this returns immediately with an empty string
cin.ignore();
This is one of the many reasons I hate using iostream. It's super confusing and filled with these kinds of gotchas. I still don't fully understand how it all works. Anyway, you might be able to fix this by moving the ignore() call so it's ABOVE the getline(lastName call.