P
persres
Hi,
The following code doesnt compile.
int main()
{
ifstream ftext;
string word;
vector <string> vs;
ftext.open("data.txt");
if (!ftext)
exit (-1);
while (ftext>>word) // as long as sizeof hasn't been reached
{
vs.push_back(word); //copy word to vector
}
}
(Taken from - http://www.devx.com/tips/Tip/14354).
The main problem is ftext>>word. Why cant I read an ifstream into a
string?.
I have visual studio 2008. Is there any reason why such an overload is
not provided?
Or am I doing something wrong?
Thanks
The following code doesnt compile.
int main()
{
ifstream ftext;
string word;
vector <string> vs;
ftext.open("data.txt");
if (!ftext)
exit (-1);
while (ftext>>word) // as long as sizeof hasn't been reached
{
vs.push_back(word); //copy word to vector
}
}
(Taken from - http://www.devx.com/tips/Tip/14354).
The main problem is ftext>>word. Why cant I read an ifstream into a
string?.
I have visual studio 2008. Is there any reason why such an overload is
not provided?
Or am I doing something wrong?
Thanks