I am trying to write a certain number of bytes, pointed by a pointer, p, to a file called myfile.
myfile=fopen("out.txt","w"); //returns a <Bad Ptr>
I noticed that myfile has a value 0x57251448 but it also says <Bad Ptr>. However, i read some confusing remarks on the web saying that might not necessarily mean something bad i,e <Bad Ptr> might just mean NULL pointer.
However, when i proceed with that in mind and I do memcpy, Visual Studio crashes and I am sent to some dbgheap.c file where I get an error at
/* check if the heap was not allocated by _aligned routines */
if ( nBlockUse == _NORMAL_BLOCK)
if ( CheckBytes((unsigned char*)((uintptr_t)pUserData & ~(sizeof(uintptr_t) -1)) -nAlignGapSize,_bAlignLandFill, nAlignGapSize))
// We don't know (yet) where (file, linenum) pUserData was allocated
_RPT1(_CRT_ERROR, "The Block at 0x%p was allocated by aligned routines, use _aligned_free()", pUserData);
errno = EINVAL;
What's the best way to write a chunk of memory , pointed to by a pointer, to a file? And what is wrong with the current way I am doing things?