I would like to store lines in a file such as
15 1 0 0 0 0
33 1 0 0 0 0
29 1 0 0 0 0
18 1 0 0 0 0
25 1 0 0 0 0
to become elements of an array. So if I do
#include <stdio.h>
#include <vector>
using namespace std
char* file = "somefile.txt"
FILE *fb_r = fopen(file,"r");
char line[100];
vector <char> lineArr;
string lineElement;
while(fgets(line,256,fb_r){
sscanf(line, "%s", &lineElement);
lineArr.push_back(lineElement); //problem arises here
}
but I get the error :
Can’t call vector >::pushBack(lineElement)
Well your vector contains single
charsand it looks like you are trying to push an
std::string?