write uint8_t type to a file C++

Viewed 11742

I have a pointer of type uint8_t *ptr type, that is pointing to a some 32 bytes of binary data. I would like to print the content that my pointer is pointing to , to a file in C++. I am going with the binary mode i.e

ofstream fp;
fp.open("somefile.bin",ios::out | ios :: binary );
//fp.write( here is the problem )
fp.write((char*)ptr,sizeof(ptr));

Is there a way I can do it so that I print out the contents that ptr is pointing to because the way I have just shown, I get 8 bytes of data in the file while it is pointing to 32 bytes of data.

2 Answers
Related