Valhalla Legends Archive

Programming => General Programming => Topic started by: DarkOne on February 11, 2003, 06:58 PM

Title: Help is needed!
Post by: DarkOne on February 11, 2003, 06:58 PM
Could anyone help me by posting a simple example in Visual Basic demonstrating how to store text from a text file to an array line-by-line so I could then further manipulate those strings which were stored in the array?
Title: Re: Help is needed!
Post by: Eibro on February 11, 2003, 07:06 PM
Sure!
using std::string;

std::vector<string> file_contents;
std::ifstream fin("filename.txt", std::ios::in);

string temp;
while (std::getline(fin, temp))
   file_contents.push_back(temp);

Title: Re: Help is needed!
Post by: Zakath on February 11, 2003, 07:28 PM
First of all, std::string?!! Why?!

Second, he wanted Visual Basic code. :P
Title: Re: Help is needed!
Post by: DarkOne on February 12, 2003, 01:03 PM
I don't speak CPP  :-/

Thanks for trying  ;)
Title: Re: Help is needed!
Post by: Eibro on February 12, 2003, 05:35 PM
QuoteFirst of all, std::string?!! Why?!

Second, he wanted Visual Basic code. :P
Bah! [link=http://www.parashift.com/c++-faq-lite/containers-and-templates.html#faq-34.1]Why not?[/link]
Title: Re: Help is needed!
Post by: Zakath on February 13, 2003, 07:26 AM
Ewww!

*notes that his first C++ instruction book taught pointers and arrays well before it ever touched the standard templates*