1
2// C program to Append a Character to a String
3
4#include <stdio.h>
5#include <string.h>
6
7int main()
8{
9 // declare and initialize string
10 char str[6] = "Geek";
11
12 // declare and initialize char
13 char ch = 's';
14
15 // print string
16 printf("Original String: %s\n", str);
17 printf("Character to be appended: %c\n", ch);
18
19 // append ch to str
20 strncat(str, &ch, 1);
21
22 // print string
23 printf("Appended String: %s\n", str);
24
25 return 0;
26}