String Concatenation

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

int main() {
    // String concatenation
    char firstName[20] = "John";
    char lastName[20] = "Doe";
    char fullName[40];

    strcpy(fullName, firstName); // Copy the first name to the full name
    strcat(fullName, " ");      // Concatenate a space
    strcat(fullName, lastName);  // Concatenate the last name

    printf("Full Name: %s\n", fullName);

    return 0;
}
chevron_left
chevron_right

Leave a comment

Your email address will not be published. Required fields are marked *

Comment
Name
Email
Website