How to print the address value of a pointer in a C program?

后端 未结 5 1509
走了就别回头了
走了就别回头了 2021-01-03 12:42

I\'m trying to learn how to use the pointer in a C program; my example is as follows:

   #include 
   #include 
   
   int mai         


        
5条回答
  •  感情败类
    2021-01-03 13:27

    p is the conversion specifier to print pointers. Use this.

    int a = 42;
    
    printf("%p\n", (void *) &a);
    

    Remember that omitting the cast is undefined behavior and that printing with p conversion specifier is done in an implementation-defined manner.

提交回复
热议问题