很抽象的问题 : 指针和地址用法
#include <iostream>int main()
{
// Intrinsic type variables.
char c = 'A';
int i = 123;
long l = 54321;
float f = 3.45;
// Pointers.
char* cp; // to char
int* ip; // to int
long* lp; // to long
float* fp; // to float
// Assign variable addresses to pointers.
cp = &c;
ip = &i;
lp = &l;
fp = &f;
// Reference the variables through the pointers.
std::cout << *cp << std::endl;
std::cout << *ip << std::endl;
std::cout << *lp << std::endl;
std::cout << *fp << std::endl;
return 0;
}
输出是 :
A
123
54321
3.45
我不明白为什麼输出是这样,谁可教教我 ? 十分感谢 ^^