I am trying to write a code that asks for the user first and last name and concatenate the function displaying the user's lastname and then firstname example:
bob allen // first and then last name
allen, bob // last and then first name using the concatenate function:
This is what I done so far, this is my first time using this function my book C for dummies doesn't explain much for me or my book on-line
#include <stdio.h>
#include <string.h>
main()
{
char str1[40];
char str2[40];
int name;
printf("Please enter your first name: ")
scanf("%d", &first);
printf("\nPlease enter your last name: ")
scanf("%d", &last);
printf("\n%s\n", strcat(str2, str1));
getchar();
return 0;
}
But I was able to get this to work:
#include <stdio.h>
#include <string.h>
main()
{
char str1[25]="James";
char str2[]="Ballard";
printf("\n%s\n", strcat(str2, str1));
getchar();
return 0;
}
I got this one off of an on-line book example.