I'm pretty new to c++. I'm reading the contents of a file into a structure like so:
struct wavObj {
uint8_t *dataBuffer; // the data
int readFile( const char *filePath );
};
int wavObj::readFile( const char *filePath ) {
FILE *file = NULL; // File pointer
file = fopen( filePath, "rb" );
dataBuffer = new uint8_t[data_Size];
fread(dataBuffer, data_Size, 1, file);
fclose(file);
return 0;
}
Do i need to use the delete operator somewhere to delete wavObj.dataBuffer? Will this struct get destroyed when the program ends, and will the memory allocation get destroyed as well? If not, can i make a destructor that uses the delete operator?