【c语言】自己的strncpy与库里的strncpy区别
来源:互联网 发布:网络三国官网 编辑:程序博客网 时间:2024/04/28 06:56
// 自己的strncpy与库里的strncpy区别#include <stdio.h>#define CHAR char#define ULONG unsigned longCHAR *VOS_strncpy(CHAR *pcDest, const CHAR *szSrc, ULONG ulLength){CHAR *pcPoint = pcDest;// 对指针进行判空if ((NULL == szSrc)||(NULL == pcDest)){return NULL;}while (ulLength && (*pcPoint = *szSrc)){pcPoint++;szSrc++;ulLength--;}// 区别来了,如果拷贝完了原先的字符串里还有东西就在后边放一个‘\0’if (!ulLength){*pcPoint = '\0';}return pcDest;}int main(){CHAR szStrBuf[] = "1234567890";CHAR szStrBuf1[] = "1234567890";strncpy(szStrBuf, "ABC", strlen("ABC"));VOS_strncpy(szStrBuf1, "ABC", strlen("ABC"));printf("Str1 = %s\nStr2 = %s\n", szStrBuf, szStrBuf1);return 0;}
0 0
- 【c语言】自己的strncpy与库里的strncpy区别
- memcpy 与 strncpy的区别
- strcpy与strncpy的区别
- strcpy与strncpy的区别
- strncpy 与 lstrcpyn 的区别
- strcpy与strncpy的区别
- Strcpy与strncpy的区别
- strcpy与strncpy的区别
- strcpy()与strncpy()的区别
- strcpy,strncpy的区别
- C语言strcpy,strncpy的用法
- C语言的strcpy()和strncpy()函数
- strncpy与strcpy的区别与注意事项
- snprintf与strncpy的一点区别。。。
- 关于lstrcpyn与strncpy的一点区别
- strcpy函数与strncpy的区别
- 【面试题】C语言:模拟实现strncpy,尝试比较strncpy与strcpy区别。
- C语言里的几个拷贝函数memcpy、memset、strcpy、strncpy
- linux 安装dubbo+zookeeper
- JNI搭建:native方法注册或NDK中的方法对应
- web.py中关于url的总结
- ZendGuardLoader
- 短信验证码自动填充
- 【c语言】自己的strncpy与库里的strncpy区别
- Leetcode Binary Tree Level Order Traversal II 二叉树分层遍历
- 警告: 未提供 -tsa 或 -tsacert, 此 jar 没有时间戳。如果没有时间戳, 则在签名者证书的到期
- do{...}while(0)的意义和用法(转)
- afx_msg解释
- MySQL数据库自动备份
- Linux下ffmpeg添加 x265
- SSH常见面试题
- adb remount of system failed: Permission denied