Here is the listing of C programming examples on String Operations.
1. C Examples on Palindrome
A palindrome is a sequence of characters which reads the same from left to right and right to left. There are many methods to check if a given string is Palindrome. They are 1) using recursion and 2) without using a built-in function. The following section contains C programs which check if the given string is a Palindrome using the methods mentioned above and one more program in the section prints the smallest and the largest possible word from the string which is a palindrome and also in a string which is not a palindrome.
2. C Examples on String Operations
The following section contains programs which deal with performing operations on a string. These operations include Concatenation and Comparison. The process of joining two strings end-to-end is called Concatenation. The process of comparing the contents of two strings for their equality is called Comparison. The section contains programs which illustrate the above operations. A portion of the given string is called substring. There are also programs in the section which check if the given string contains a substring and finds the length of the string without using a built-in function.
3. C Examples on Replace, Remove and Reverse Functions
The following section deals with three more operations that can be performed on a given string. They are Replace, Remove and Reverse. Replace function replaces the occurrences in a given string. Remove deletes the characters from the specified positions and Reverse function reverses the characters of a string. The C programs in this section uses the replace function to replace lowercase characters by uppercase and vice-versa, to replace all string characters by lowercase. It removes a given word from the string, removes all the repeated words in a string, removes all the characters in the second string which are present in the first string.The C programs also use the reverse function to reverse the string using recursion and iteration both and to reverse every word of the given string. The remaining C programs demonstrate the count operation. They count the number of vowels and consonants in a section and counts the total number of words in a sentence using command line argument.
4. C Examples on finding the Frequency of Occurrences of Characters in a String
The repetition of the characters in a string is called Frequency. The following section contains C Programs which finds the frequency of the word ‘the’ in a given sentence, finds the number of times the substring occurs in the given string, to find the frequency of every word in a given string and to find the highest frequency character in a string. The section also illustrates the use of copy function which copies one string to another using recursion and a program which reads a given string and finds the sum of all the digits in a string. Then we have programs which use the concept of recursion. These programs include a program to find the first capital letter in a string using recursion and a program to find the string length using recursion. Other programs in this section include a program to find the repeating sequence that is the longer, program to find the length of the longest repeating sequence in a string and a program to find all the possible subsets of a string.
5. C Examples on Displaying, Inserting and Printing the Characters in a String
An anagram is the process of finding a new word by rearranging the original letters of the word. The program in the following section checks if the two given strings are anagrams. The remaining programs in the section deal with listing, displaying, inserting and printing the characters or the words. It has programs to display the possible combination of 3 strings from the given strings without any repetitions, program to list all the lines contained in the given string, a program to print the all the possible words ending with the letter S and a program to insert character/word in a desired location in a string.
6. C Examples on Implementation of Functions and Algorithms
The following section contains C programs that implement certain functions. These functions include regular expression matching, strpbrk() function and KMP pattern searching algorithm. The strpbrk() function is used to search a string with a specified characters. The remaining programs in the section demonstrate the use of sort function. The programs include sorting a word in a given string, sorting the string by ignoring white-spaces and repeating characters only once and sorting the string and displaying the repeated characters only once.
7. C Examples on the usage of Count Function and Search Method
The programs in this section illustrates the use of count function and search method. The count function is used to count the number of occurrences of the given word in a string and the search method searches for the specified word in the string. The programs in this section counts the number of unique words, counts the number of words in a given text or sentence and searches for a word in the given string and replaces it with a given specified word. It also has programs to display the characters at a specified position in the given string and display the combination of two words of two given strings without any repetition.
8. C Examples demonstrating the Occurrences in a given String
The following section contains C programs which deals with the number of occurrences in a string. These occurrences can be word occurrences, character occurrences or substring occurrences. It has programs which count the number of occurrences of each character ignoring the case of alphabets and displays them, counts the occurrences of each C keyword using array structure, program to find the first occurrence of a character of one string in the other string, program to find the first and last occurrence of a given character in a string and a program to count the occurrence of a substring in a given string.
9. C Examples demonstrating Simple Mathematical Operations on Strings
Ordered arrangement of objects in a circular manner is called Circular permutation. The section contains a C program to determine if one string is a circular permutation of other. The other C programs in the section illustrate mathematical operations like calculating the binary sum of 2 binary strings which are given as the input to the program, printing the squares of all the numbers in a string, converting an integer to a string and vice versa and finding the sum of ASCII values of all the characters in a given string.