实现strncpy函数
来源:互联网 发布:数据接口技术规范 编辑:程序博客网 时间:2024/06/05 09:36
#include <iostream>#include <assert.h>using namespace std;//实现strncpy函数,注意啊,中间带个N,就是从源字符串复制多少个过来,//返回值为目标字符串的地址是为了实现链式操作 char* strncpy(char *strDest, const char *strSrc, unsigned int count)//注意这里的CONST,指向的内容不能修改 {assert(strDest != NULL && strSrc != NULL); //断言保证传进来的两个参数不是空char * address = strDest;while ( count-- && *strSrc != '\0') //一直赋值,赋值为‘\0’的时候结束{*strDest++ = *strSrc++;}*strDest = '\0';return address;}int main(void){ char *s = "hello world";char *t = "hello";char a[10] = {0};strncpy(a, t, 4);cout<<a; system("pause"); return 0;}
- 自己实现strncpy函数
- 实现strncpy函数
- strncpy函数的实现
- 模拟实现strncpy函数
- 模拟实现 strncpy( )函数
- strcpy、memcpy、strncpy函数实现
- C语言strncpy函数实现
- 实现strcpy( )和strncpy( )函数
- 模拟实现strcpy,strncpy函数
- C语言 strncpy函数实现
- strcpy和strncpy函数实现
- strcpy()函数与strncpy()函数实现
- strcpy,strncpy, strlen, strcmp strcat函数实现
- strcmp、strcat、strcpy、strncpy函数的实现
- 【C语言】模拟实现strcpy()、strncpy()函数
- strncpy函数
- strncpy() 函数
- strncpy() 函数
- sencha touch 2.2.0 环境配置
- 转自matrix67 十个利用矩阵乘法解决的经典问题
- 类的成员函数与外部函数的区别
- 通过ajax实现异步刷新
- devexpress gridview排序
- 实现strncpy函数
- 用平淡的心情去看待seo
- struts2+jQuery+jSon需要导入的包
- poj 1861 Network
- 指向数组的指针
- Oracle常用的OCI函数
- 移动互联网长连接
- 申请openshift帐号
- poj 2362 hdoj 1518 Square(搜索)