How to Append a Character to a String in C

Given a string str and a character ch, this article tells about how to append this character ch to this string str at the end.


Input: str = "Geek", ch = 's'
Output: "Geeks"

Input: str = "skee", ch = 'G'
Output: "skeeG"


  1. Get the string str and character ch
  2. Use the strncat() function to append the character ch at the end of str. strncat() is a predefined function used for string handling. string.h is the header file required for string functions.


    char *strncat(char *dest, const char *src, size_t n)

    Parameters: This method accepts the following parameters:

    • dest: the string where we want to append.
    • src: the string from which ā€˜nā€™ characters are going to append.
    • n: represents the maximum number of character to be appended. size_t is an unsigned integral type.
  3. Print or return the appended string str.

Below is the implementation of the above approach:





// C program to Append a Character to a String
#include <stdio.h>
#include <string.h>
int main()
    // declare and initialize string
    char str[] = "Geek";
    // declare and initialize char
    char ch = 's';
    // print string
    printf("Original String: %s\n", str);
    printf("Character to be appended: %c\n", ch);
    // append ch to str
    strncat(str, &ch, 1);
    // print string
    printf("Appended String: %s\n", str);
    return 0;



Original String: Geek
Character to be appended: s
Appended String: Geeks

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Recommended Posts:

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :


Please write to us at to report any issue with the above content.