Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[blue]
#include <vector> [green]//Place this with the rest of the includes [/green]
vector <string> myData; [green]//A vector of strings[/green]
[green]//Do some file reading stuff here
You are probably using fstream?
So reading the file would be like:
[/green]
while(myFile.eof()!)
{
myStream.getline(SomeCharBuffer,1000);
[green]//As you are reading data in you can push things on to the back of the vector[/green]
myData.push_back(SomeCharBuffer);
}
[green]//When you are done you can iterate through the vector just as you could with a standard array [/green]
for (int i =0;i<(int)myData.size();i++) cout << myData[i] << endl;
[/blue]
#include <fstream>
using std::ifstream;
#include <vector>
using std::vector;
#include <string>
using std::string;
int main()
{
ifstream fileIn( "C:\\myfile.txt" );
string buf;
vector<string> myArray;
while ( fileIn.eof() == false )
{
fileIn.get( buf, ',' );
myArray.push_back( buf );
}
fileIn.close();
// Now do something with the array...
return 0;
}