Ask the user for his first and last name. : String Read « String « C Tutorial






#include <stdio.h> 
    #include <string.h>

    int main() {   
        char first[100];
        char last[100]; 
        char full[200];            

        printf("Enter first name: ");  
        fgets(first, sizeof(first), stdin);

        printf("Enter last name: ");   
        fgets(last, sizeof(last), stdin);  

        strcpy(full, first);   
        strcat(full, " "); 
        strcat(full, last);

        printf("The name is %s\n", full);  
        return (0);
    }
Enter first name: string
Enter last name: last
The name is string
 last








3.3.String Read
3.3.1.Read string from keyboard
3.3.2.Reading Strings
3.3.3.Ask the user for his first and last name.