ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

C String Programs

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

  1. 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.
  2. 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.
  3. C program to create and print array of strings.
    This program will create, read and print an array of string in C programming language.
  4. 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).
  5. 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.
  6. 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.
  7. ADVERTISEMENT

  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. 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.
  14. 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.
  15. 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.
  16. 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).
  17. 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.
  18. 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?
  19. 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 .
  20. 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?
  21. 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.
  22. 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?
  23. 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?
  24. C program to check a string is palindrome or not without using library function
    Given a string, we have to check whether the given string is palindrome or not without using library function.
  25. C program to check a string is palindrome or not using recursion
    Given a string, we have to check whether the given string is palindrome or not using recursion.
  26. C program to print the biggest and smallest palindrome words in a string
    Given/Input a string (with multiple words), and then print the biggest and smallest palindrome words from the given string using C program.
  27. C program to print the smallest word in a string
    Given a string, we have to print the smallest word from the given string using C program.
  28. C program to print the biggest word in a string
    Given a string, we have to print the biggest word from the given string using C program.
  29. C program to reverse a string using recursion
    Read a string and then reverse a string using recursion.
  30. C program to reverse every word of the given string
    Read a string and then reverse every word of the given string using C program.
  31. C program to remove a given word from the string
    Read a string from the user then remove the given word from the string using C program.
  32. C program to delete duplicate words in the string
    Read a string from the user then remove duplicate words from the string using C program.
  33. C program to sort strings in alphabetical order
    Given an array of strings, we have to sort strings in alphabetical order using C program.
  34. C program to find the frequency of the given word in a string
    Read a string and a word from the user, then find the frequency of the word in the string using C program.
  35. C program to find the sum of all digits in the alphanumeric string
    Read an alphanumeric string from the user, then find the sum of all digits present in the string using C program.
  36. C program to copy a string to another string using recursion
    Read a string from the user and copy the string into another string using a recursive user-defined function.
  37. C program to find the first capital letter in a string using recursion
    Read a string from the user and find the first capital letter in a string using recursion.
  38. C program to find the first capital letter in a string without using recursion
    Read a string from the user and find the first capital letter in a string without using recursion.
  39. C program to find the frequency of every word in the given string
    Read a string from the user and find the frequency of each word in the input string using C program.
  40. C program to find the highest frequency of a character in the given string
    Read a string from the user and find the highest frequency of a character in the given string using C program.
  41. C program to print all possible subsets of a given length in string
    Read a string from the user and find all possible subsets of a given length in the string using C program.
  42. C program to check two strings are anagram or not
    Read two strings from the user and check whether the given strings are anagram or not using C program.
  43. C program to find a specific word ends with a specific character in the string
    Read a string and a character from the user and check words is ending is the specific character within the string using C program.
  44. C program to split the string using the strtok() function
    In this program, we will use the strtok() function. This function is used to split the string and get words from a specified string based on a specified delimiter.
  45. C program to split the string using strtok_r() function
    In this program, we will use strtok_r() function. This function is used to split the string and get words from a specified string based on a specified delimiter.
  46. C program to demonstrate the strstr() function
    In this program, we will use the strstr() function. This function is used to find the first occurrence of a specified substring within the string and return the pointer to the calling function. It returns NULL if the substring is not found within the string.
  47. C program to implement own strstr() function
    In this program, we will implement a user-defined function to perform a similar operation to the strstr() function.
  48. C program to demonstrate the strpbrk() function
    In this program, we will search the first vowel within the string using the strpbrk() function. The strpbrk() function accepts two string parameters. And, search any character of the second string within the first string passed as an argument in the function and returns the character pointer to the calling function.
  49. C program to implement the strpbrk() user-defined function
    In this program, we will implement strpbrk() user-defined function to search the first vowel within the string using the strpbrk() function. The strpbrk() function accepts two string parameters. And, search any character of the second string within the first string passed as an argument in the function and returns the character pointer to the calling function.
  50. C program to sort the words of the string
    Read a string from the user, then sort the words of strings using C program.
  51. C program to implement the KMP pattern search algorithm
    Read a string from the user, then find the word in the string using the KMP pattern search algorithm, and print the index of the word within string on the console screen.
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.