The file output with selection of the shortest words in C++
Tell me what was the error, why the short function words is not working and how to insert the selection of words in the text the smallest?
Asked: 11-11-2012 в 09:33:20
In your function SamKorotkSlov() (at least here in the above code), there are no input data from the file into str. Why do You open the file many times and in different styles (C++, C)? Just one, then it can be re-read from the beginning. -In fact (assuming that the word is also limited by the end of the line) a single pass of reading the file line by line. Along with checking the length of a string, you can choose from it the words and store the shortest (You know, there might be several) in the array. At the end you can print them from this array. What is not clear - ask. - 11-11-2012 в 18:37:27
As I understand it You need to find the word with maximum length, although the name of the function, with a minimum of:) Here is an example for a search with a minimum length of:
To search with a maximum length change the line
Well, rename the variables for readability.
SUPPLEMENT ON THE ALLOCATION
For highlighted words with a minimum length, use the function SetConsoleTextAttribute. For example according to the following algorithm: remember the length of the minimal words in the text, and then printing to console the text one word at a time (do not forget about punctuation and spaces) and, if the word length is equal to the minimum, then set the text color, e.g. to red, displaying the word and then return the white color. Something like this:
Answered: 11-11-2012 в 10:25:10
no you are right with the minimum long you need to find, thank you very much for the help, and how to highlight these words in the text, when you press any buttons I don't understand how to do it - 11-11-2012 в 11:22:04
In the text, I mean in the file? - 11-11-2012 в 11:32:37
and it's why that little word seeks in one line, and how to make all the Teks, please help - 11-11-2012 в 11:38:23
Generally it is strange. I looking for the file. - 11-11-2012 в 11:57:23
@Daniel, (as I understand it Your answer) and why such a strange ...|| min == -1) to find minimum? In General, the highs-lows of the types prescribed in