Home > Back-end >  Open the file in read mode, each word as a separate element for storage
Open the file in read mode, each word as a separate element for storage

Time:09-21

 void FCN (const string& The filename, vector & Vec) 
{
Ifstream in (filename);
If (in)
{
String buf.
While (in> Buf)
{
Vec. Push_back (buf);
}
}
The else
cout <"Fail to open the file!" }

Why a "in the while in> Buf "can solve will be in according to the content of a word as a separate element in the vec?
  • Related