Hi all,
I working in VC++. I have a void pointer. I am assigning a memory block to it using malloc().
void* buf_ptr = NULL;
buf_ptr = malloc(1428480);
I am filling this buffer using fread(). and I want to index this buffer (buf_ptr) to acces its data. How can I do that.
I am facing the following errors.
Error 24 error C2036: 'void *' : unknown size c:\AMT_DLL_tester.cpp
Error 25 error C2440: '=' : cannot convert from 'void' to 'void *' c:\AMT_DLL_tester.cpp
Here is my source code
FILE *f_in = NULL;
f_in = fopen(argv[f],"rb"
);
if
( f_in == NULL )
{
fprintf(fptr,"ERROR: Could not open '%s'\n"
, argv[f] );
fclose(fptr);
return
1;
}
int
buf_size = 1428480;
void
*buf_ptr = NULL;
buf_ptr = malloc(buf_size+1);
items = fread(buf_ptr,buf_size,1,f_in);
void
* ptr = buf_ptr[20]; //----------->error
Please guide me how can I access the data of a void type buffer?
Your help will be highly appreciated..
Many Thanks.
Asif Javaid