Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

perl

Name: Anonymous 2007-10-04 22:09

In perl, how would one read a text file into an array such that each word (as separated by whitespace) would become a different element?

Name: Anonymous 2007-10-05 5:43

>>5
I pick C++

ifstream ifs("file.txt");
vector<string> words;
string file, word;
getline(ifs,line,(char)EOF);
istringstream is(line);
while (is) {
    is >> word;
    words.push_back(word);
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List