Home »
C programs
C language String solved Programs/Examples
String is the set of characters which is declared as character array, in this section you will find solved programs/examples on C language string with output and explanation.
Most of the program will have user defined functions, in some cases we may use library functions.
List of string programs in C
- C program to print indexes of a particular character in a string.
This program will read a string and a character to find its indexes where character exists in C programming language.
- C program to compare two strings using pointers.
This program will read two strings and compare them character by character using pointers in C programming language.
- C program to create and print array of strings.
This program will create, read and print an array of string in C programming language.
- C program to capitalize first character of each word in a string.
This program will read a string and print in Capitalize form where first character of each word will be capital (uppercase) and other characters will be small (lowercase).
- C program to find the frequency of a character in a string.
This program will read a string and character to find it frequency and print frequency of given character in input string.
- C program to read a string and print the length of the each word.
This program will read a string and print the length of each word, for example, if input is “Hi there how are you?” then output will be 2, 5, 3, 3, 4.
- C program to eliminate/remove all vowels from a string.
This string program will read a string and eliminate/remove all vowels from input string.
- C program to eliminate/remove first character of each word from a string.
This string program will read a string from the user and eliminate/remove first character of each word of input string in C programming language.
- C program to read n strings and print each string's length.
In this article, we will read n strings from the input and store it in array and print the length of each string in the array.
- C program to copy one string to another and count copied characters.
In this C program, we are going to learn how to copy one string to another without using any library function? Here, we will also get the total number of copied characters and printing them.
- C program to remove all spaces from a given string.
In this C program, we are going to learn how to remove all spaces from a given string? Here, we will have a string with spaces and program will remove all spaces and print the string without spaces.
- C program to convert a string to sentence case.
In this C program, we are going to learn how to convert a given string to sentence case. To implement this logic, we are creating a user define function to do the same.
- C program to remove alphabets from an alphanumeric string.
In this C program, we are going to learn how to remove alphabets from a given alphanumeric string? If string contains alphabets and numbers both, this program will remove only alphabets from the string.
- C program to eliminate all vowels from a string.
In this C program, we are going to learn how to eliminate all vowels from a given string? Here, we have a string that may contain consonants, vowels etc we have to remove only vowels from it.
- C program to swap adjacent characters of a string.
In this C program, we are going to learn how to swap adjacent characters of a string? Here, we will have a string with even number of characters (string length must be even to swap the adjacent characters).
- C program to read time in string format and extract hours, minutes and second also check time validity.
In this C program, we are going to read time in string forma (the specified time format will be HH:MM:SS) and program will extract the hours, minutes and seconds also checking time validity.
- Creating string buffer (character pointer), allocating memory at run time in C.
Here, we are going to learn how to create a character pointer (string buffer), how to declare memory at run time in C language?
- memcpy() function in C with Example.
string.h – memcpy() function with example: Here, we are going to learn about the memcpy() function – which is used to copy a block of memory from one location to another .
- Write your own memcpy() function in C.
Here, we are going to learn how to write your own memcpy() function to copy blocks of memory from one location to another?
- memset() function in C with Example.
string.h memset() function with example: Here, we are going to learn about the memset() function of string.h in C/C++ language, which is used to fill a block of memory with the given value.
- Write your own memset() function in C.
Here, we are going to learn how to write your own memset() function to fill blocks of memory with a particular value in C?
- C program to compare strings using strcmp() function.
C language strcmp() function example: Here, we are going to learn how to compare two strings using strcmp() function in C programming language?
TOP Interview Coding Problems/Challenges