c 指针打印变量_C程序打印不同类型的指针变量的大小。
c 指針打印變量
Any type of pointer variable takes the same memory bytes in the memory, because they are used to store the memory addresses on other type of variables.
任何類型的指針變量都在內存中占用相同的內存字節,因為它們用于在其他類型的變量上存儲內存地址。
Let’s take an example - There are two pointers 1) integer pointer and 2) char pointer, integer pointer will take 4 bytes (in case of, 32 bits compiler) and will store the address of integer variables only. char pointer will also take 4 bytes but it will store the address of only char variable.
讓我們舉個例子 -有兩個指針1) 整數指針和2) char指針 ,整數指針將占用4個字節(對于32位編譯器而言),并將僅存儲整數變量的地址。 char指針也將占用4個字節,但它將僅存儲char變量的地址。
In this C program, we are testing the same by printing the size of different types of pointers.
在此C程序中,我們通過打印不同類型的指針的大小來進行測試。
C程序打印不同類型指針的大小 (C program to print sizes of different type of pointers )
</ s> </ s> </ s> /*C program to print size of different types of pointer variables.*/ #include <stdio.h>int main() {printf("\nsize of char pointer: %d" ,sizeof(char*));printf("\nsize of int pointer: %d" ,sizeof(int*));printf("\nsize of float pointer: %d" ,sizeof(float*));printf("\nsize of long int pointer: %d" ,sizeof(long int*));printf("\nsize of double pointer: %d\n" ,sizeof(double*));return 0; }Output
輸出量
size of char pointer: 4size of int pointer: 4size of float pointer: 4size of long int pointer: 4size of double pointer: 4~~~~ Output depends on the system architecture,
~~~~ but each type of pointer will take same memory space ~~~
~~~~輸出取決于系統架構,
~~~~但是每種類型的指針都會占用相同的內存空間~~~
翻譯自: https://www.includehelp.com/c-programs/c-pointer-program-to-print-size-of-different-types-of-pointer-variables.aspx
c 指針打印變量
總結
以上是生活随笔為你收集整理的c 指针打印变量_C程序打印不同类型的指针变量的大小。的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 抛硬币正面期望_如果抛硬币,正面的数量多
- 下一篇: 检查不孕不育去哈尔滨哪家医院好