4 回答
TA贡献1840条经验 获得超5个赞
1 2 3 4 | vector<unsigned char> data; ofstream f("in.dat", ios::binary); unsigned char c; while(f>>c) data.push_back(c); |
TA贡献1836条经验 获得超3个赞
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | include <vector> #include <iostream> using namespace std ; typedef struct Data { unsigned char idrecord[11]; //id unsigned char ctype[7]; //type unsigned int od; unsigned char id; } data_t ; //这个类型要定义成全局的! int main() { data_t d[]={ { "111","10",1,11}, { "222","11",2,22}, { "333","12",3,33} }; vector <data_t> vst ; int i; for( i=0;i<3;i++ ) vst.push_back( d[i] ); for( i=0;i<3;i++ ) { cout << vst[i].idrecord <<endl; } return 0; } |
- 4 回答
- 0 关注
- 824 浏览
添加回答
举报