Strings in C Programming
Concatenation
Concatenation is the process of combining two or more strings to form a single
string.
In C, strings can be concatenated using the strcat() function from the string.h library.
Example:
#include <string.h>
#include <stdio.h>
int main() {
char str1[20] = "Hello, ";
char str2[20] = "world!";
char str3[40];
strcat(str3, str1);
strcat(str3, str2);
printf("%s\n", str3); // Output: "Hello, world!"
return 0;
}
Length
The length of a string can be determined using the strlen() function from the string.h
library.
Concatenation
Concatenation is the process of combining two or more strings to form a single
string.
In C, strings can be concatenated using the strcat() function from the string.h library.
Example:
#include <string.h>
#include <stdio.h>
int main() {
char str1[20] = "Hello, ";
char str2[20] = "world!";
char str3[40];
strcat(str3, str1);
strcat(str3, str2);
printf("%s\n", str3); // Output: "Hello, world!"
return 0;
}
Length
The length of a string can be determined using the strlen() function from the string.h
library.