I read a integer binary file to int vector. When I use the Sort function the vector is zeroing...
I know the vector is OK!
What could be wrong?
std::ifstream input("D:\\Amostra.txt", ios::binary); vector<int> v (NumBlocks*ELEMENTS_PER_BLOCK*sizeof(int)); input.read(reinterpret_cast<char *>(&v[0]), NumBlocks*ELEMENTS_PER_BLOCK*sizeof(int)); sort(v.begin(), v.end()); for (int i=0; i<ELEMENTS_PER_BLOCK*NumBlocks; i++){ cout << v[i] << endl; }; system("pause");
inttochar*. I don't think that's really supposed to work? I are you sure you don't wantcharinstead?NumBlocks