标准 C 函数的缩写方式是否有任何基本原理?例如,malloc()
是“内存分配”的缩写。 sprintf()
是“格式化的字符串打印”。这些名称都不能很好地告诉您函数的实际作用。直到最近我不得不教一个新实习生许多这样的函数时,我才意识到这些缩写函数名称中的一些有多么可怕。
在开发该语言时,是否有任何理由选择 malloc()
而不是 memAllocate()
或类似的东西?我最好的猜测是它们更类似于 UNIX 命令,但这并不是正确的答案。
最佳答案
查看 http://publications.gbdirect.co.uk/c_book/chapter2/keywords_and_identifiers.html -
The problem is that there was never any guarantee that more than a certain number of characters would be checked when names were compared for equality—in Old C this was eight characters, in Standard C this has changed to 31.
基本上,在过去(很久以前)您只能指望函数名称中前八个字符的唯一性。因此,您最终会得到一堆核心功能的简称。
关于c - 标准 C 函数名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31526626/