V2EX  ›  英汉词典

Calloc

释义 Definition(中文)

calloc 是 C 语言标准库中的内存分配函数,用来为“若干个元素”分配一段连续内存,并且会把分配到的内存全部初始化为 0(或等价的全零位模式)。常见原型:void *calloc(size_t n, size_t size);
(除内存分配外,它也常被用于“获得一个已清零的数组”。)

发音 Pronunciation(IPA)

/ˈkæl.ɒk/

例句 Examples

I used calloc to create an array of 10 integers.
我用 calloc 创建了一个包含 10 个整数的数组。

If calloc returns NULL, the program should handle the allocation failure and avoid dereferencing the pointer.
如果 calloc 返回 NULL,程序就应该处理分配失败,并避免对该指针进行解引用。

词源 Etymology(中文)

calloc 通常被认为来自 clear + alloc(ate) 的合成/缩写:强调“分配(allocate)并清零(clear)”。它作为 C 运行库/标准库接口名称而流行,用于与 malloc(只分配不清零)形成对比。

相关词 Related Words

文学与著名作品用例 Literary Works(中文)

  • 《The C Programming Language》(Kernighan & Ritchie):在内存管理与动态数组相关示例/讨论中常与 mallocfree 并列出现。
  • 《C Programming: A Modern Approach》(K. N. King):讲解动态内存分配时会介绍 calloc 的用途与与 malloc 的差异。
  • 《Advanced Programming in the UNIX Environment》(W. Richard Stevens):在讲述系统编程与内存分配实践时常提及 calloc/malloc 等接口。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1127 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 17ms · UTC 16:54 · PVG 00:54 · LAX 08:54 · JFK 11:54
♥ Do have faith in what you're doing.