file - how to get int with fstream get() in c++ -
i newer c++, going creating file, , write int values want int values function!(here excepted type of return int ) index file, going put int values! found both fstream.put , fstream.get operate char values. there me, how job. , here code
vector<int> tra1; vector<int> tra2; int last_capa = 0; for(int i=1;i<97;i++){ output.put(tra1[i-1] * 5 + tra2[i-1] + last_capa); last_capa += (tra1[i-1] - 1) * 5 + tra2[i - 1]; }
below code read int here try int number operate
vector<int> tra4 output.seekg(100); unsigned int n = output.get() + tra4[2];
thanks help
haoran
alternatively instead of get, can use fstream's operator >> read value file int.
fstream fs("input.txt", std::fstream::in); //input file int k; while(fs >> k) { //do k } fs.close();
Comments
Post a Comment