sizeof

    2热度

    1回答

    成员初始值设定项中使用的sizeof的行为是什么?我无法找到关于这个的描述。在下面的代码示例中它是安全的吗?即struct会员编译后会把A正确的大小写入b? struct A { int a = 0; int b = sizeof(A); int c = 3; int d = 4; char s[256]; A() {

    2热度

    2回答

    ‪#‎include‬ <stdio.h> #include <string.h> int main() { printf("%d\n",sizeof("S\065AB")); printf("%d\n",sizeof("S65AB")); printf("%d\n",sizeof("S\065\0AB")); printf("%d\n",sizeof

    0热度

    5回答

    以下是我的代码: #include <stdio.h> struct abc { char a; int b; }; int main() { struct abc *abcp = NULL; printf("%d", sizeof(*abcp)); //Prints 8 /* printf("%d",*abcp); //Cau

    1热度

    3回答

    在下面的代码中,当我获取第一个if的条件的值时,它是0,因此是错误的。仍然,输出打印“浮动”。这是短路的结果吗?如果是这样,为什么在“正常”情况下不会发生这种情况,sizeof运算符未与'=='一起使用? #include<stdio.h> int main() { int x=1; short int i=2; float f=3; if(sizeo

    1热度

    1回答

    根据MSDN文档的Visual Studio 2012,streamsize可被定义如下: #ifdef _WIN64 typedef __int64 streamsize; #else typedef int streamsize; #endif 然而检查实际源iosfwd定义似乎是如下(注意没有条件): typedef _Longlong streamsize;

    -4热度

    2回答

    我想创建一个char foo[]并设置大小为int,但它根本无法工作! }else{ int start = match[1].rm_so; int end = match[1].rm_eo; char value[end-start]; ... } value的大小始终为0,为什么这样呢? 谢谢

    51热度

    4回答

    我发现MSVC和GCC编译器为每个类实例分配至少一个字节,即使这个类是一个没有成员变量(或者只有静态成员变量)的谓词。以下代码说明了这一点。 #include <iostream> class A { public: bool operator()(int x) const { return x>0; } }; class B { pub

    -1热度

    1回答

    我测试地看到,NULL常量确实占据了指针的大小尺寸比较: ASSERT(sizeof NULL == sizeof(char*)); 不过,我不小心写的,而不是执行以下操作: ASSERT(sizeof NULL == sizeof char); 这应该编译,而是它给了我下面的错误: error: expected expression before ‘char’ 同样happene

    3热度

    3回答

    标准C(ISO/IEC 9899:1999)第6.5.3.4说 sizeof运算符不应被应用于具有 功能型或表达不完整的类型 但是为什么? 使用readelf检查可执行文件显示,在编译过程中函数的大小完全知道。 Symbol table '.symtab' contains 67 entries: Num: Value Size Type Bind Vis Ndx Name ..

    2热度

    2回答

    struct t{ char days[20]; int date; char x; struct t *next; }*head printf("%ld\n", sizeof(head)); 其中sizeof(*void)=8,sizeof(int)=4,sizeof(char)=1 为什么它打印8?