Read a piece of text into a vector object. Each word is stored as an element of a vector. Converts each word in a vector object to an uppercase letter. Output the converted elements in a vector object. Each eight words are output in one row.
# Include "stdafx. H "# include <iostream> # include <fstream> # include <vector> # include <string> using namespace STD; int main () {vector <string> text; string line; string word; string filepath = "C: \ cc.txt"; // ifstream fin (filepath. c_str (); While (! Fin. EOF () {Getline (FIN, line); // read row for (string: size_type I = 0; I <line. size (); ++ I) {If (line [I]> = 'A' & line [I] <= 'Z ') // convert line [I]-= 32; If (line [I] = ''| line [I] = '\ t') {If (! Word. empty () {text. push_back (Word); word = "" ;}} elseword + = line [I];} text. push_back (Word); word = "" ;}// output for (string: size_type I = 0; I! = Text. Size (); ++ I) {cout <text [I] <""; if (I % 7 = 0 & I! = 0) cout <"\ n";} getchar (); Return 0 ;}
[Where do I forget the program. Familiar with container vector/file stream ifstream/C ++ usage]