小编gre*_*bit的帖子

输入一个字母“int”

代码:

int a;
cin>>a;
cout<<a<<endl;
Run Code Online (Sandbox Code Playgroud)

然后我使用g++ test.cpp并运行它。然后我向变量 a 输入字母“b”。输出为0。

但是,当我测试其他代码时:

cout<<int('b')<<endl;   // output: 98
Run Code Online (Sandbox Code Playgroud)

为什么?有什么不同?

c++ type-conversion

5
推荐指数
1
解决办法
7431
查看次数

C++地址值和sizeof

在我的电脑上.当我测试代码时:

int main()
{
    int i=123;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

运用

g++ -g test.cpp -o test
Run Code Online (Sandbox Code Playgroud)

我进入时发现:

print &i            output: 0x7fffffffe18c
print sizeof(&i)    output: 8
Run Code Online (Sandbox Code Playgroud)

我很困惑,我的地址是6字节,为什么sizeof(&i)==8?非常感谢

c c++ sizeof

2
推荐指数
1
解决办法
192
查看次数

标签 统计

c++ ×2

c ×1

sizeof ×1

type-conversion ×1