大佬教程收集整理的这篇文章主要介绍了指针是什么(详解版),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
char letter; short number; float amount;图 1 说明了它们在内存中是如何安排的,并显示了它们的地址。
&amount
以下语句可以将变量的地址显示到屏幕上://This program uses the & operator to determine a variable's address. #include <iostream> using namespace std; char letter; short number; float amount; double profit; char ch; int main() { // Print address of each variable // The cast to long makes addresses print in decimal // rather than in hexadecimal cout << "Address of letter is: " << long(&letter) << endl; cout << "Address of number is: " << long(&number) << endl; cout << "Address of amount is: " << long(&amount) << endl; cout << "Address of profit is: " << long(&profit) << endl; cout << "Address of ch is: " << long(&ch) << endl; return 0; }程序输出结果:
Address of letter is: 5005320
Address of number is: 5005322
Address of amount is: 5005324
Address of profit is: 5005328
Address of ch is: 5005336
以上是大佬教程为你收集整理的指针是什么(详解版)全部内容,希望文章能够帮你解决指针是什么(详解版)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。