C Program to concatenate two String Utilizing strcat() operate

Programmer's Academy 

 

 

Algorithm:

 

step 1:begin

 

step 2:declare a,b as character array

 

step 3:enter a,b 

 

step 4:carry out strcat() operation

 

step 5:print the concatenated string

 

step 6:cease

 

 

 

Flowchart:

 

Code:

 

Programmer's Academy


#embody <stdio.h>

#embody<string.h>

int essential() {

    char a[100],b[100];

    printf(“Enter Your Title:”);

    will get(a);

    printf(“Enter Your Surname:”);

    will get(b);

    strcat(a,b);

    printf(“Your full title is %s,a);

    

    

    return 0;

}

Pattern Enter and Output:

Enter Your Title:Pankaj                                                                                                                 

Enter Your Surname:Jaiswal

Your full title is PankajJaiswal            

Rationalization of above program 

 

In above Program we’re concatenating one string with one other string utilizing strcat() operate

char *strcat(char *vacation spot,char *supply)

The full type of strcat()  operate is string concatenation.It is without doubt one of the inbuilt string operate which is offered by string.h header file in C,it helps to concatenate two string those that do not what’s concatenation,it’s nothing however combining one string with one other,I identified most of you continue to have the confuse for  the identical,So Let’s take an instance to know extra clearly.

first_string=”Good”

second_string=”Morning”

strcat(first_string,second_string)

After passing above two string values to strcat() operate the end result can be GoodMorning and it will likely be saved within the vacation spot argument i.e first_string(as per syntax of strcat()).We will merely say that the results of concatenation of first_string and second_string shall be saved in first_string.

Now Let’s Perceive the code line by line which now we have written above

For understanding extra clearly about C Program to concatenate two String Utilizing strcat() operate now we have took the instance wherein Person will put his/her first and final title and our program will give him his/her FullName.

Within the first line of code we’re importing stdio.h header file which assist us to make use of printf() and scanf().stdio.h is a acronym of ordinary enter output header file.Within the subsequent line we’re importing string.h header file which give totally different string associated features like strcmp(),stringcpy(),strcat(),

places(),will get() and lots of extra.

After that now we have outlined essential operate wherein now we have written all of the assertion that are going to be executed,as we identified the execution of c program begins from essential() operate solely.

Within the subsequent line,now we have declared two character array(string) specifically a,b which we shall be utilizing to saved two string respectively.After that now we have printed one assertion “Enter Your First Title” which assist the consumer to get to identified that the appliance is ready in your enter.For taking consumer enter as string or character array now we have used will get() operate.As soon as the consumer put his/her first title this system will ask for lastname(right here additionally we’re doing the identical factor which we have been doing for firstname),the second consumer put his/her final title the concatenated results of two string shall be printed,to attain this we’re concatenating two string utilizing strcat() functiom which now we have already seen above the way it works.

Within the subsequent line of code we’re printing the results of concatenation utilizing printf() operate.Right here now we have written printf(“Your Full title is  %s”,a).Right here “Your Full title is” shall be printed as it’s and the worth of  a personality array wherein the concatenated sting is saved shall be printed.

Within the final line of code we’re merely returning return 0 which imply that the execution of program is generally executed.It’s essential to return the worth if now we have wrote the int return of any operate,In our case it’s essential() which is int return sort.

Should you any have doubt,suggestion relating to this put up or web site then be happy to share with us.

 

In case you have realized one thing new from this put up then share this put up with your loved ones and
buddies.

 

Blissful Studying :)?   

 

Earlier
Subsequent

(Visited 10 times, 1 visits today)

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
Ask ChatGPT
Set ChatGPT API key
Find your Secret API key in your ChatGPT User settings and paste it here to connect ChatGPT with your Tutor LMS website.
0
Would love your thoughts, please comment.x
()
x