我想将行存储在文件中,例如
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
成为数组的元素。所以如果我这样做
#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
}
但我收到错误:
无法调用向量 >::pushBack(lineElement)