Friday, October 16, 2009

concating two string in C

strcat takes two char * arguments and returns the concatenated string as a char *. Here's a simple use of strcat:
#include 
#include

int main() {
char str1[50] = "Hello ";
char str2[] = "World";

strcat(str1, str2);

printf("str1: %s\n", str1);

return 0;
}

Output:

str1: Hello World

No comments: