你好我都是新手编程,我有一个范例,我需要打印一个结构类型的指针,它在每次迭代中动态获取值,并打印一个defrenced结构成员每次迭代。打印一个结构指针和一个推定的struct成员
struct my_struct
{
int x;
int y;
}
void function(){
my_struct* a=value.get() // some values will be assigned dynamically to this pointer from other part of function.
my_struct* data = new thread_data;
data->x=1 //which will get updated according the iterations and conditions
data->y=2 //which will get updated according the iterations and conditions
}
现在我需要在调用函数中打印a,x,y的值,如何打印这些值。 一些像
printf("a=%lx x=%i y=%i\n", a,x,y);
有人可以请给我一些想法或如何进行?非常感谢
使用'%p'打印指针。检查'man 3 printf'。 – 2013-03-19 13:39:42