sizeof

    0热度

    1回答

    产生的数据类型,我被人比我更了解的是,sizeof操作符不产生类型“为size_t”的值,而是产生具有相同的基本类型“为size_t”的值告诉。虽然这可能是比语义技术性罢了,C++ 11 5.3.3.6和C++ 14 5.3.3.6双方声明如下: The result of sizeof and sizeof... is a constant of type std::size_t. [ Not

    3热度

    4回答

    #include <stdio.h> int main() { short int a; char c; printf("%d %d %d",sizeof(a),sizeof(c),sizeof(c+a)); } 4字节而不是在该函数sizeof一个是炭的2字节大小为1个字节,但我把它们加起来它给4字节。它在表达式中做了什么来使其成为4

    20热度

    2回答

    我在.H struct buf_stats { // *** }; 限定的结构然后在.c文件 struct buf_stats *bs = malloc(sizeof(struct buf_states*)) ; 其中buf_states是一个错字。 但GCC不提醒我,虽然我以前-Wall 和这个bug /错字我花了3个小时找到。 如何使gcc警告未定义的结构像这样?

    0热度

    1回答

    我不是在寻找一个恒定的记录最大值可用int代表;我正在寻找一个int可以占用的最大内存量。请看下面的代码: import sys def print_and_execute(*args): for s in args: print(s, end = " == ") r = eval(s) print(r) return print_a

    3热度

    2回答

    在这段代码中,我得到一个不同的sizeof(T)如果分配器 是一个容器配置的一部分: #include <iostream> #include <set> #include <cstddef> class Item { int a; unsigned char b, c, d; int e, f, g; public: Item()

    2热度

    6回答

    我熟悉C中的sizeof操作,但是当我将它用于字符串"1234abcd"时,它只返回4,我假设它是会计最后4个字符。 那么我怎么会得到这是一个字符串大小为8? 具体代码如下: FILE *in_file; in_file = fopen(filename, "r"); if (in_file == NULL) { printf("File does not exist\n");

    0热度

    1回答

    我读一个名为data.txt与如下所示: b 5 b 2 b 9 每行有3个特点:空间在标签之间。 我有以下代码一次只读一行。 int main(int argc, char * argv[]){ FILE * filePointer; filePointer = fopen("data.txt", "r"); char singleLine[3*sizeof

    7热度

    2回答

    我一直认为由sizeof返回的T类型的N个元素的数组的大小保证是N次sizeof(T)的N倍。 comments on this question让我怀疑它。有信誉良好的用户声称数组可能包含填充,这将打破平等。当然,这样的平台可能不存在,但它们允许吗? 如果允许,这会打破很多常见的习惯用法,例如使用N * sizeof(T)计算数组所需的存储空间,或者使用sizeof(a)/sizeof(a[0]

    -5热度

    2回答

    enter image description here prog.c: In function 'main': prog.c:7:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=] printf("%d",siz

    51热度

    3回答

    该程序应打印出array的元素,但运行时不显示输出。 #include <stdio.h> #define TOTAL_ELEMENTS (sizeof(array)/sizeof(array[0])) int array[] = { 23, 34, 12, 17, 204, 99, 16 }; int main() { int d; for (d = -1; d