/*
* C++中输出字符变量地址时要把其强制转换成“void *”格式。否则会显示乱码。
*(未定义内存的填充值为0xCC,如果以字符串形式输出就是“烫烫烫...”)。
*/
#include <iostream>
using namespace std;
* C++中输出字符变量地址时要把其强制转换成“void *”格式。否则会显示乱码。
*(未定义内存的填充值为0xCC,如果以字符串形式输出就是“烫烫烫...”)。
*/
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
int i = 0;
char ch = '\0';
{
int i = 0;
char ch = '\0';
cout << "input a integer: " << endl;
cin >> i;
cin >> i;
cout << "input a character: " << endl;
cin >> ch;
cin >> ch;
cout << "i == " << i << endl;
cout << "ch == " << ch << endl;
cout << "ch == " << ch << endl;
cout << "&i == " << &i << endl;
cout << "&ch == " << &ch << endl;
cout << "&ch == " << &ch << endl;
cout << "(void *)&i == " << (void *)&i <<endl;
cout << "(void *)&ch == " << (void *)&ch << endl;
cout << "(void *)&ch == " << (void *)&ch << endl;
system("pause");
return 0;
}
return 0;
}
转载于:https://blog.51cto.com/programs/235798