getchar() Function in C — Read a Character with Example

The getchar() function reads a single character from standard input (the keyboard) and returns it. It is one of the simplest input functions in C and a great way to understand how the input buffer works. In this program we use getchar() in a loop to read text entered by the user and count how …

C program to find the character type.

The ctype.h header provides a set of functions for testing and converting individual characters. Each function takes an int (the ASCII value of a character) and returns a non-zero value (true) if the character belongs to a certain class. They are used in parsers, tokenizers, input validation, and any code that processes text character by …

C Program to sort the string, using shell sort technique.

Shell sort is a generalization of insertion sort that sorts elements far apart before sorting adjacent ones. Invented by Donald Shell in 1959, it repeatedly applies insertion sort on sublists of decreasing “gap” sizes until the gap reaches 1 — at which point one final insertion sort on the nearly-sorted array runs in near-linear time. …

C program to delete n Characters from a given position in a given string.

Deleting n characters from a given position in a string is a common string manipulation task used in text editors, parsers, and data cleaning. The approach: shift all characters after the deleted region one step to the left, overwriting the deleted characters, then terminate the string with a null byte. The original post used gets() …

C program to insert a sub-string in to given main string from a given position.

C Strings:C Program to insert a sub-string in to given main string from a given position. In this program we read two strings and replace the second string in the given position of the first string.Read more about C Programming Language . /************************************************************ You can use all the programs on www.c-program-example.com* for personal and learning …

C Program to Compare Two Strings – Manual and strcmp()

This C program compares two strings and reports whether they are equal, or which one comes first in dictionary (lexicographic) order. Comparison works character by character: walk both strings together until two characters differ or a string ends, then decide from that first difference. This page shows a manual character-by-character implementation and the standard library …