I was wondering if there is a more efficent way to calculate actual size in bytes of any file,
here is how I am doing.
win32 API which will do it for me. accuracy is important as I will be reading the entire file in to a shared buffer.
I am hoping how many times the loops run will tell me the actual size in bytes. Once I know what the size is then I can allocate memory and read the entire file all at once in to the shared buffer.Code:fstream reader("myfile",std:ios:binary| std::ios::in); unsigned int counter =0; unsigned char myReader; while(!reader.eof) { reader.read((char *)&myReader,sizeof(unsigned char)); counter++ } reader.close(); unsigned int filesize = counter;




Reply With Quote