| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 382 人关注过本帖
标题:关于函数名称的小问题
只看楼主 加入收藏
ouyangshit
Rank: 3Rank: 3
来 自:China
等 级:论坛游侠
帖 子:155
专家分:107
注 册:2014-10-25
结帖率:100%
收藏
已结贴  问题点数:8 回复次数:8 
关于函数名称的小问题
像 strcpy 是 string copy 来的
   strcat 是 string contact
   gets   是 get string
之类的。

那么问题来了:
calloc() malloc() 是怎么来了。我知道alloc是allocate.
顺带问一下 printf,scanf 的f是什么 ,function?
搜索更多相关主题的帖子: function contact 
2014-11-14 08:09
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
这有意义吗   即便我取名为add 我可以用来实现减法或者查询啥的

DO IT YOURSELF !
2014-11-14 08:15
ouyangshit
Rank: 3Rank: 3
来 自:China
等 级:论坛游侠
帖 子:155
专家分:107
注 册:2014-10-25
收藏
得分:0 
回复 2 楼 wp231957
名称的定义我觉得就是要 见名知义 。
我觉得能知道组成函数名的词根能更好的让我这个小菜鸟记忆和运用 。
2014-11-14 08:22
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:0 
malloc --- allocate memory
printf --- format print
2014-11-14 09:12
ouyangshit
Rank: 3Rank: 3
来 自:China
等 级:论坛游侠
帖 子:155
专家分:107
注 册:2014-10-25
收藏
得分:0 
回复 4 楼 rjsp
calloc() 呢?
2014-11-14 09:14
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:0 
回复 5 楼 ouyangshit
这是一个迷,永远没答案,不过Brian Kernighan曾猜测可能是clear。
2014-11-14 09:47
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:8 
你在网上搜索一下,比如
http://cn.
能看到各种说法,随便贴一个你瞧瞧
The meaning of the c in calloc was vividly discussed in comp.lang.c in October 2000 (see here), with both clear (because, unlike malloc, calloc clears the memory it returns) and count (because, unlike malloc, calloc is passed a count of elements to allocate) suggested as possible explanations, however without real evidence for either. Other suggestions were (along with several less serious ones) contiguous, core, commit, chunk, and character, the latter because in early versions of K&R C, calloc was the only allocation function in the library (and had an accompanying cfree). For the same reason, it was even suggested that the c simply stand for the C programming language. So, the etymology of calloc still isn't proven, and if anybody has any definite evidence as to its meaning, I'd highly appreciate learning about it.
2014-11-14 09:54
八画小子
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:37
帖 子:709
专家分:2063
注 册:2010-11-11
收藏
得分:0 
函数名称经过编译器编译后,其实就是程序在内存中代码段的一个地址,名称怎么编写都是这样的。不过名称的编写符合一定的命名规则有助于提高代码的可读性,方便交流。
2014-11-14 10:24
ouyangshit
Rank: 3Rank: 3
来 自:China
等 级:论坛游侠
帖 子:155
专家分:107
注 册:2014-10-25
收藏
得分:0 
回复 7 楼 rjsp
感谢版主,说的太好了!
我也搜了一些,满足了我的好奇心和求知欲。
2014-11-14 12:25
快速回复:关于函数名称的小问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015571 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved