简体   繁体   中英

How to print value of void pointer if its a structure member

Here I have a structure with name param and a structure member is void pointer now I want to print the value of void pointer in hex for 500 times.

struct param
{
   void * tc_data;
}
param_t param_data;

UINT32 temp_index2=0;
UINT32 *pc = (UINT32*)param_data.tc_data;
for (temp_index2 =0;temp_index2<500;temp_index2++)
{ 
   printf (" DATA =%x\n", pc[temp_index2]);
}

The way I am, its print only address but I want to print the value. Any help with explanation would be great.

May you are having confusion with hex and decimal data. You are printing data in hex and assuming that is the address. If you want to see in decimal do:

printf (" DATA =%d\n", pc[temp_index2]); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM