sizeof

    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()

    -1热度

    4回答

    空数组我怎样理解这一点: 我的编译器抱怨:错误:使用GNU空初始化扩展。 gcc和Clang可以编译并运行它。语法与double pert[]有什么不同?或double *pert; 在这个例子中,per t甚至没有[0],那么pert[0]怎么可能有意义呢?是的,我想这跟sizeof(double)一样。 特别是,我分析的代码在阵列上使用了很多sizeof,所以我不想将[]更改为*不必要的;

    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");

    -4热度

    2回答

    /**** Program to find the sizeof string literal ****/ #include<stdio.h> int main(void) { printf("%d\n",sizeof("a")); /***The string literal here consist of a character and null character,

    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

    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

    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