1.

What is concatenation? Explain with example.OrExplain the mechanism of Concatenation of a new word in a string.

Answer»

Concatenation: Concatenation means joining of two different strings to form one string. In ‘C’, streat function is used to do concatenation.

STRCAT(): This function appends or concatenates the source string at the end of the target string. For example, “Rajeev” and “Sharma” on concatenation would result in a string “Rajeev Sharma”. The length of the resulting string is strlen(dest) + strlen(src).
Example:

void main()
{
char src[ ] = “Rajeev”;
char tgt[ ] = “Sharma”;
strcat (tgt, src);
printf (“\n source string = % s”, src);
printf (“\n target string = % s”, tgt);
}

Output:

source string = Rajeev

target string = Sharma Rajeev.



Discussion

No Comment Found