I wrote this function, I want that simply reads a binary file and returns a vector with the content of the file. I follow some tutorial about how use "fread" but I have a segmentation violation. Can you help me to understand this?
const std::vector<uint32_t> read() {
//obtain file size
fseek( fBinaryFile, 0, SEEK_END );
long lsize = ftell( fBinaryFile );
rewind( fBinaryFile );
uint32_t pDataBuffer[sizeof( uint32_t )*lsize];
//read file
fread( pDataBuffer, sizeof( uint32_t ), lsize, fBinaryFile );
std::vector<uint32_t> cVector( pDataBuffer, pDataBuffer + sizeof( uint32_t )*lsize );
closeFile();
return cVector;
}