C Programming code for Merging Multiple Strings – KLETech

Write a Modular C Programming Code for Merging Multiple Strings | Words?

CODE:

#include<stdio.h>
#include<string.h>
#define MAX_LENGTH 50
void print_full_name(char fn[], char mn[],char ln[]);
main()
{
char first_name[MAX_LENGTH];
char mid_name[MAX_LENGTH];
char last_name[MAX_LENGTH];
printf("enter your first name, middle name and last name\n");
scanf("%s%s%s",first_name, mid_name,last_name );
print_full_name( first_name, mid_name, last_name);
}
void print_full_name(char fn[], char mn[],char ln[])
{
char full_name[MAX_LENGTH];
strcpy(full_name,fn);// copy first name into full name
strcat(full_name," ");// concat a space to the end.i.e after first name
strcat(full_name,mn);//concat middle name.
strcat(full_name," ");
strcat(full_name,ln);
printf("\nFull name is: %s\n",full_name);
}

 

OUTPUT

enter your first name, middle name and last name
KLE
Technological
University

Full name is: KLE Technological University

Process returned 0 (0x0) execution time : 30.148 s
Press any key to continue.

 

Please find some more codes of 1D Arrays, 2D Arrays, Pointers on the below page:

Top 100+ C Programming codes – KLE Technological University

 

Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

Welcome to FactsPrime

Sorry, We have detected that you have activated Ad-Blocker. Please Consider supporting us by disabling your Ad Blocker, It helps us in maintaining this website. To View the content, Please disable adblocker and refresh the page.

Thank You !!!