Home > Back-end >  For help, questions about the call file
For help, questions about the call file

Time:09-27

 
Void fill_completion (vector C_dict, fstream fd) {
Fd. Open (the file, the ios: : | in ios: : out);
string s;
while (! Fd. Eof ())
{
Getline (fd, s);
The transform (s.b do v.begin (), s.e nd (), s.b do v.begin (), : : tolower);//Lowercase all the word
S.e rase (remove_if (s.b do v.begin (), s.e nd (), static_cast & lt; Int (*) (int) & gt; (& amp; Ispunct)),
S.e nd ());//erase the symbol if a word has
//remove the word with only one letter
Stringstream ss (s);
The string word;
While (ss & gt; & gt; Word) {
If (word size ()==1) {
continue;
}
C_dict. Push_back (word);
}
}
Fstream ofs (file, the ios: : out | ios: : app);
Cout & lt; <"Do you want to fill the library (y/n)?" char ch;
Cin & gt; & gt; Ch;
String STR.
vector arr;
The string word="";

While (ch!='n') {
Cout & lt; <"Which word do you want to add?" ;
Cout & lt; <"(like 'app', you can enter 0, a, a, p, 2, p)" & lt; While (true) {
Getline (cin, STR);
{if (STR=="#")
break;
}
for (int i=0; i Word +=STR [I + 2];
}
}
Cout & lt; <"The new word:" & lt;
C_dict. Push_back (word);
//sort all the words and get the unique word
Sort (c_dict. The begin (), c_dict end ());
C_dict. Erase (unique (c_dict. The begin (), c_dict. The end ()), c_dict. The end ());

For (vector : : iterator iter=c_dict. The begin (); Iter!=c_dict. End (); + + iter) {
Ofs & lt; <* iter & lt; }
Fd. The close ();
Ofs. Close ();
}
}

Int main () {
Fstream ifs.
string s;
vector C_dict;

The ifs. Open (the file, the ios: : | in ios: : out | ios: : binary | ios: : app);
Fill_completion (c_dict, ifs);

The ifs. Close ();
}

I'm fill_completion () want to invoke open a TXT file, but said error cannot use have been deleted in the inside of the main function, solving!!!!!!

CodePudding user response:

  • Related