Skip to content

Instantly share code, notes, and snippets.

@franzejr
Created November 16, 2012 00:48
Show Gist options
  • Save franzejr/4082874 to your computer and use it in GitHub Desktop.
Save franzejr/4082874 to your computer and use it in GitHub Desktop.
Get strings from a file and save into a vector<string>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main(){
char temp[200];
vector<string> strings;
FILE *arquivo = fopen("strings","r");
for (int i=0; i< 10000; i++) {
fscanf(arquivo, "%s", temp);
string str_temp = temp;
strings.push_back(str_temp);
}
for(int i = 0; i < strings.size(); i++){
cout << strings[i];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment