首頁  >  文章  >  後端開發  >  C 中 printf 中的「%p」有什麼用?

C 中 printf 中的「%p」有什麼用?

王林
王林轉載
2023-08-27 21:29:022333瀏覽

C 中 printf 中的“%p”有什么用?

在C語言中,我們已經看過不同的格式說明符。這裡我們將看到另一個稱為%p的格式說明符。它用於列印指標類型的資料。讓我們看一個示例以更好地理解。

範例

#include<stdio.h>
main() {
   int x = 50;
   int *ptr = &x;
   printf("The address is: %p, the value is %d", ptr, *ptr);
}

輸出

The address is: 000000000022FE44, the value is 50

以上是C 中 printf 中的「%p」有什麼用?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除