Showing posts with label strcat() c. Show all posts
Showing posts with label strcat() c. Show all posts

Friday, December 18, 2020

, ,

Example program for strcat() function in c

 If you have a computer programming background then we believe you heard the name of concatenation this word in programming language is known for joins to strings.

program for strcat() function in c
Example program for strcat() function in c

Here in c language strcat() function in c use to joins two given string in c programs. 

Syntax for strcat c

char *strcat(char *destination, const char *source)

strcat c function defines in string.h header file.

strcat() c arguments

strcat() function use two arguments

  • destination - first one is destination string.
  • source - source of the string is second one.

strcat() function in c add  destination string and the source string and final result will be stored in destination string.

Example program for strcat() c

 

#include <stdio.h>
#include <string.h>
int main() {
   char str1[100] = "This is ", str2[] = "functioninc.in";

   // concatenates str1 and str2
   // the resultant string is stored in str1.
   strcat(str1, str2);

   puts(str1);
   puts(str2);

   return 0;
}