Home / Programs / Write a program that demonstrates the joining of two strings using library function strcat( ).
Programming Example

Write a program that demonstrates the joining of two strings using library function strcat( ).

👁 1,164 Views
💻 Practical Program
📘 Step by Step Learning
Write a program that demonstrates the joining of two strings using library function strcat( ).

Program Code

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

int main()
{
  char s[30] ="Hello,";
  char str[] ="world!";

  printf("%s\n", s);
  strcat(s, str);

  printf("%s\n", s);
 
  return 0;
 }

Output

Hello,
Hello,world!

 

Explanation

None

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.