C Program to Extract Characters From a String Last Updated : 19 Jul, 2022 Comments Improve Suggest changes Like Article Like Report Character extraction can be done by iterating through the string in the form of a character array. It basically means plucking out a certain amount of characters from an array or a string. Now, to take input in C we do it by using the following methods: scanf("%c",&str[i]); - Using a loopscanf("%s",str); - Using %s format specifiergets(str); - Gets gives us an extra ability to use space in an character string/arrayNow the next step would be running the loop until we reach the null pointer, which exists in character arrays to indicate the end of the string. Being cautious, we will check for no blank space, if it is a valid character we print it using ("%c ",str[i]) else we will continue. Example: C // C Program to demonstrate character // extraction from a string #include <stdlib.h> #include <stdio.h> int main() { char str[20]; printf("Enter the string: "); gets(str); // alternative scanf("%s",str); // character extraction printf("Printing the characters:: \n"); for (int i = 0; str[i] != '\0'; i++) { if (str[i] != ' ') { // not a white space printf("%c\n", str[i]); // printing each characters in a new line } } return 0; } Input: GeeksforGeeksOutput: Enter the string: GeeksforGeeks Printing the characters:: G e e k s f o r G e e k s Time Complexity: O(n) where n is the size of the string. Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article C Program to Extract Characters From a String I iamsuman898 Follow Improve Article Tags : C++ Programs C++ Practice Tags : CPP Similar Reads How to Extract a Substring from a Character Array in C++? In C++, character arrays are used to store sequences of characters also known as strings. A substring is a part of a string that consists of a continuous sequence of characters from the string. In this article, we will learn how to extract a substring from a character array in C++. Extract a Substri 2 min read How to Remove Last Character From C++ String? In C++, strings are stored as the std::string class objects. In this article, we will look at how to remove the last character from this C++ string object. For Example, Input: Hello! GeeksOutput: Hello! GeekRemove the Last Character from a String in C++To remove the last character from a string, we 2 min read C++ Program to Print the First Letter of Each Word of a String String str is given which contains lowercase English letters and spaces. It may contain multiple spaces. Get the first letter of every word and return the result as a string. The result should not contain any space. Examples: Input: str = "geeks for geeks" Output: gfg Input: str = "happy coding" Out 4 min read How to Read a File Character by Character in C++? In C++, file handling is used to store data permanently in a computer. Using file handling we can store our data in secondary memory (Hard disk). In this article, we will learn how to read a file character by character in C++. Example: Input: "Geeks for Geeks"Output: G e e k s f o r G e e k sRead Te 2 min read Extract and print words separately from a given Camel Case string Given a string in Camel Case format, we need to extract all the words which are present in the string. CamelCase is the sequence of one or more than one words having the following properties: It is a concatenation of one or more words consisting of English letters.All letters in the first word are l 6 min read Like