如何找到数组的大小(从指向第一个元素数组的指针)?
作者:jkidv 提问时间:1/30/2009
首先,这里有一些代码: int main() { int days[] = {1,2,3,4,5}; int *ptr = days; printf("%u\n", sizeof(days)...
sizeof 问答列表
作者:jkidv 提问时间:1/30/2009
首先,这里有一些代码: int main() { int days[] = {1,2,3,4,5}; int *ptr = days; printf("%u\n", sizeof(days)...
作者:Neeraj-Kumar-Coder 提问时间:1/4/2021
当我在函数中使用此代码时,数组的大小(或长度)被正确计算:main() #include <stdio.h> int main(void) { int arr[] = {2, 5, 9, 8, ...
作者:Hobbes 提问时间:5/13/2023
我在 StackOverflow 答案 (https://stackoverflow.com/a/3331268/17342809) 下阅读了这条评论: 内存分配请求应尽可能与类型无关:不要对内存分...
作者:Bernd Klein 提问时间:10/29/2023
我尝试在 EPS32 上将结构转换为字节流。 在我的结构/联合下面。 #include <Arduino.h> typedef struct { uint16_t header; float ...
作者:Some Name 提问时间:10/28/2023
请考虑以下代码: #include <stdio.h> #include <limits.h> #include <inttypes.h> #include <stddef.h> int main...
作者:jkidv 提问时间:1/30/2009
首先,这里有一些代码: int main() { int days[] = {1,2,3,4,5}; int *ptr = days; printf("%u\n", sizeof(days)...
作者:Some Name 提问时间:10/13/2023
我正在使用以下版本的 gcc: $ gcc --version gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 请考虑以下简单的代码片段:-Werror=sign...
作者:Kirill Afentev 提问时间:10/10/2023
请考虑以下继承: struct Empty {}; struct A: Empty { int64_t a; int8_t b; }; struct B: A { int32_t c; }...
作者:ben 提问时间:10/9/2023
我需要获取字符串的大小以传递给函数 read() 下面是我尝试实现的代码,使用函数 size 查找字符串的大小,但它不起作用 #include <stdlib.h> int main() { ...
作者:Shaler 提问时间:9/26/2023
int *p_numbers; p_numbers = malloc((sizeof *p_numbers) * 10); if (p_numbers == NULL) exit(EXIT_F...