Print value and address of pointer defined in function?

后端 未结 5 2030
[愿得一人]
[愿得一人] 2021-02-07 23:29

I think this is a really easy thing to code, but I\'m having trouble with the syntax in C, I\'ve just programmed in C++.

#include 
#include 

        
5条回答
  •  半阙折子戏
    2021-02-07 23:50

    #include 
    #include 
    
    void pointerFuncA(int* iptr){
    /*Print the value pointed to by iptr*/
    printf("Value:  %p\n", (void*) iptr );
    
    /*Print the address pointed to by iptr*/
    
    /*Print the address of iptr itself*/
    }
    
    int main(){
    int iptr = 0;
    pointerFuncA( &iptr); 
    
    return 0;
    }
    

    I think you are looking at something like this, there is no need to re-define the function again in the main....

提交回复
热议问题