linux系统库函数之strcat、strncat
来源:互联网 发布:windows平板刷安卓 编辑:程序博客网 时间:2024/06/05 18:18
165 /**
166 * strcat - Append one %NUL-terminated string to another
167 * @dest: The string to be appended to
168 * @src: The string to append to it
169 */
170 #undef strcat
171 char *strcat(char *dest, const char *src)
172 {
173 char *tmp = dest;
174
175 while (*dest)
176 dest++;
177 while ((*dest++ = *src++) != '\0')
178 ;
179 return tmp;
180 }
181 EXPORT_SYMBOL(strcat);
182 #endif
用于将src所指向的字符串拷贝到dest所指向字符串末尾。
184 #ifndef __HAVE_ARCH_STRNCAT
185 /**
186 * strncat - Append a length-limited, %NUL-terminated string to another
187 * @dest: The string to be appended to
188 * @src: The string to append to it
189 * @count: The maximum numbers of bytes to copy
190 *
191 * Note that in contrast to strncpy(), strncat() ensures the result is
192 * terminated.
193 */
194 char *strncat(char *dest, const char *src, size_t count)
195 {
196 char *tmp = dest;
197
198 if (count) {
199 while (*dest)
200 dest++;
201 while ((*dest++ = *src++) != 0) {
202 if (--count == 0) {
203 *dest = '\0';
204 break;
205 }
206 }
207 }
208 return tmp;
209 }
210 EXPORT_SYMBOL(strncat);
211 #endif
同strcat函数不同的是,如果没有到字符串结尾,它只拷贝count大小字节数据,并且在dest末尾加上字符串的结束符'/0'
- linux系统库函数之strcat、strncat
- linux----strcat、strncat
- 字符串库函数strlen,strcmp,strcpy,strncpy,strcat,strncat自定义实现
- strcat,strncat函数实现——string.h库函数
- 实现5个库函数(my_strcmp strcat strncat my_strlen my_strstr)
- strcat和strncat函数
- strcat函数 strncat函数
- strcat strncat的使用方法
- strcat和strncat
- strcat,strncat函数
- string库之模拟实现strcat与strncat
- linux系统库函数之memcpy
- linux系统库函数之memmove
- linux系统库函数之memset
- linux系统库函数之strlen
- Linux系统库函数之strsep
- strcat 和strncat 函数学习
- strcat和strncat的实现
- 动力火车-UPS_不断电
- Linux环境下安装ruby和rails gems时,openssl和zlib报错问题的解决
- Androdi SoftReference
- Android测试教程(1):概述
- Flex 多语言 国际化 resourceManager(包括Menu语言不变情况)
- linux系统库函数之strcat、strncat
- 橡皮筋技术的实现
- C++编写的SOCKET服务器端程序
- [随即]Solaris10 安装,不能图形化安装解决方法[安装](新手贴)
- java音乐播放器
- 用Direct3D设计淡入淡出的效果
- osmf 的介绍(上)
- CAS单点登录(SSO)总结
- dispatch_async 与 dispatch_get_global_queue