Originally Posted by
kamitsuna
Reading documentation on it just doesnt register with me...i have 2 c++ books, but unless i can see it work or not work, I dont really get it.
Yeah, grokking documentation is the same as programming: the more you do it, the easier it becomes.
Usually what docs lack are working examples. Here's something that reads a text file into a vector of strings, then prints them out:
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int main() {
string name="tmp.txt";
ifstream file(name.c_str());
char buf[1024];
vector<string> data;
int i, len;
while (file.getline(buf,1024)) data.push_back(buf);
file.close();
len = data.size();
for (i=0;i<len;i++) cout << data[i] << endl;
return 0;
}