我想做一些看起来相当简单的事情.我得到了结果,但问题是,我无法知道结果是否正确.
我用C语言工作,我有两个指针;我想打印指针的内容.我不想取消引用指针来获取指向的值,我只想要指针存储的地址.
我写了下面的代码,我需要知道的是它是否正确,如果不正确,我如何纠正它.
/* item one is a parameter and it comes in as: const void* item1 */
const Emp* emp1 = (const Emp*) item1;
printf("\n comp1-> emp1 = %p; item1 = %p \n", emp1, item1 );
虽然我张贴了这一点(这一点很重要,因为它是正确的)是因为我最终需要为指向指针的指针这样做.即:
const Emp** emp1 = (const Emp**) item1;