7 Sring Handling Function in c
7 Sring Handling Function in c
h>
#include <string.h>
int main() {
char str1[50], str2[50], str3[50];
int len, cmp_result;
strncpy(str3, str1, 5); // Copying the first 5 characters of str1 into str3
str3[5] = '\0'; // Null-terminate str3
printf("str3 after strncpy: %s\n", str3);
strncat(str1, " - Demo", 5); // Append the first 5 characters of " - Demo" to
str1
printf("str1 after strncat: %s\n", str1);
return 0;
}