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

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -