【发布时间】:2015-12-31 02:02:08
【问题描述】:
我认为这是一件非常容易编码的事情,但我在 C 中的语法上遇到了问题,我刚刚用 C++ 进行了编程。
#include <stdio.h>
#include <stdlib.h>
void pointerFuncA(int* iptr){
/*Print the value pointed to by iptr*/
printf("Value: %x\n", &iptr );
/*Print the address pointed to by iptr*/
/*Print the address of iptr itself*/
}
int main(){
void pointerFuncA(int* iptr);
return 0;
}
显然,这段代码只是一个框架,但我想知道如何获得函数和主工作之间的通信,以及打印指向的地址和 iptr 本身的语法?由于该函数是无效的,我怎样才能将所有三个值都发送到 main?
我认为地址类似于:
printf("Address of iptr variable: %x\n", &iptr );
我知道这是一个简单的问题,但是我在网上找到的所有示例都得到了价值,但它在 main 中被定义为类似
int iptr = 0;
我需要创建一些任意值吗?
谢谢!
【问题讨论】: