c++打印char指针_C++程序打印不同类型的指针的⼤⼩以及值
和地址
c ++ 打印char指针
Here, we will learn how we can print the size of different type of pointer variables in c++ programming language?
在这⾥,我们将学习如何在c ++编程语⾔中打印不同类型的指针变量的⼤⼩?
We are using sizeof() operator to get the size of variables.
我们正在使⽤sizeof()运算符来获取变量的⼤⼩。
Consider the following program:
考虑以下程序:
#include <iostream>
using namespace std;
int main()
sizeof 指针{
int  *iptr;
char  *cptr;
float *fptr;
cout<<sizeof(iptr)<<","<<sizeof(cptr)<<","<<sizeof(fptr)<<endl;
cout<<sizeof(*iptr)<<","<<sizeof(*cptr)<<","<<sizeof(*fptr)<<endl;
return 0;
}
输出量 (Output)
8,8,8
4,1,4
Program is compiled and executed on a 64 bits computer system architecture, that’s why the size of the pointer is 8.
程序是在64位计算机系统体系结构上编译和执⾏的,这就是指针⼤⼩为8的原因。
In the above program, we are declaring 3 pointer variables iptr, cptr and fptr of integer, character and float type.
在上⾯的程序中,我们声明了整数,字符和浮点类型的3个指针变量iptr , cptr和fptr 。
And we are printing the size of these pointer variables along with the type of value (which will be stored in these the address stored in pointer variables).
⽽且我们正在打印这些指针变量的⼤⼩以及值的类型(值将存储在指针变量中的地址中)。
c ++ 打印char指针

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。