Popular Tutorials
Start Learning CCertification Courses
Created with over a decade of experience and thousands of feedback.
Python online compiler
JavaScript online compiler
SQL online compiler
Java online compiler
HTML online compiler
C online compiler
C++ online compiler
C# online compiler
PHP online compiler
Swift online compiler
Kotlin online compiler
TypeScript online compiler
Go online compiler
Rust online compiler
Scala online compiler
Dart online compiler
R online compiler
Ruby online compiler
C strcat()
In C programming, the strcat() function contcatenates (joins) two strings.
The function definition of strcat() is:
char *strcat(char *destination, const char *source)
It is defined in the string.h header file.
strcat() arguments
As you can see, the strcat() function takes two arguments:
destination - destination string
source - source string
The strcat() function concatenates the destination string and the source string, and the result is stored in the destination string.
Example: C strcat() function
#include <stdio.h>
#include <string.h>
int main() {
char str1[100] = "This is ", str2[] = "programiz.com";
// concatenates str1 and str2
// the resultant string is stored in str1.
strcat(str1, str2);
puts(str1);
puts(str2);
return 0;
}
Output
This is programiz.com programiz.com
Note: When we use strcat(), the size of the destination string should be large enough to store the resultant string. If not, we will get the segmentation fault error.
Did you find this article helpful?