strcpy and strcat
Completed
Read a first and last name. Build LAST, FIRST in a new buffer using strcpy and strcat, and print it with its length.
Input
Two words.
Output
Two lines.
Example
Input
Ada Lovelace
Output
Lovelace, Ada 13
Editor
C
Hints
strcpy(dest, src) copies; strcat(dest, src) appends.
The destination must be big enough.
Solution explanation
You can't use = or + on C strings - use the string.h functions.
Show solution
#include <stdio.h>
#include <string.h>
int main() {
char first[50], last[50], full[110];
scanf("%s %s", first, last);
strcpy(full, last);
strcat(full, ", ");
strcat(full, first);
printf("%s\n%d\n", full, (int) strlen(full));
return 0;
}