Given a string containing space-separated words and a number K. The task is to find and print all those words whose length is greater than K using stringstream in C++.
A general solution to solve this problem using loops is discussed in the previous article. In this article, a solution using stringstream in C++ will be discussed.
Input : str = "hello geeks for geeks is computer science portal" K = 4 Output : hello geeks geeks computer science portal Input : str = "string is fun in python" K = 3 Output : string python
The idea is to use stringstream to create a stream by splitting the given string into tokens and then process the stream and print the words with length greater than K.
Below is the implementation of the above idea:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find words which are greater than given length k
- Removing spaces from a string using Stringstream
- Count the number of words having sum of ASCII values less than and greater than k
- stringstream in C++ and its applications
- StringStream in C++ for Decimal to Hexadecimal and back
- Length of the largest substring which have character with frequency greater than or equal to half of the substring
- Check if the given string of words can be formed from words present in the dictionary
- Count of alphabets having ASCII value less than and greater than k
- Count words that appear exactly two times in an array of words
- Smallest number greater than X which is K-periodic
- Smallest Greater (than S) String of length K whose letters are subset of S
- Count number of binary strings such that there is no substring of length greater than or equal to 3 with all 1's
- Find the starting indices of the substrings in string (S) which is made by concatenating all words from a list(L)
- K length words that can be formed from given characters without repetition
- Find a string such that every character is lexicographically greater than its immediate next character
- Smallest alphabet greater than a given character
- Generating Lyndon words of length n
- Java program to print Even length words in a String
- Find and print duplicate words in std::vector<string> using STL functions
- Given a sequence of words, print all anagrams together using STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.