编写函数copy_n心得
来源:互联网 发布:中国阶层划分 知乎 编辑:程序博客网 时间:2024/06/01 16:04
在函数中我们经常使用copy_n函数实现复制的功能,它的原型如下所示:
void copy_n(char dst[], char src[], int n);
实现函数如下:
#include <stdio.h>#include <stdlib.h>#define NUM 100void copy_n(char dst[], char src[], int n);int main(){ int i; char dst1[NUM] = "123456789"; char src1[NUM] = "abcdefghijk"; copy_n(dst1, src1, 5); /*输出字符串*/ for (i = 0; dst1[i] != '\0'; i++) { printf("%c ",dst1[i]); } printf("\n"); return EXIT_SUCCESS;}void copy_n(char dst[], char src[], int n){ int i,index; for (index = 0; dst[index] != '\0'; index++) { } for (i = 0; (src[i] != '\0')&& (i < n); i++) { dst[index++] = src[i]; } dst[index] = '\0';}
- 编写函数copy_n心得
- matlab中s函数编写心得(转)
- matlab中s函数编写心得(转)
- C++ copy、copy_n、copy_if
- 编写Makefile的心得
- 驱动程序编写心得
- TypeMock测试编写心得
- EBS SQL编写心得
- winSocket编写心得
- hpp文件编写心得
- hpp文件编写心得
- Shell编写心得
- BindService demo编写心得
- 淘宝sdk编写心得
- 编写短信接收心得
- 编写openMP的心得
- STL algorithm算法copy_n(9)
- 函数心得
- ui page control and scrollview with indicator at bottom
- 怎样使一个Android应用不被杀死//Android: HowTo设置app不被系统kill掉
- 经典SQL语句大全
- Linux系统的应用软件流程图绘制软件yEd
- Ubuntu11.10+OpenCV2.3.1安装全程(二)
- 编写函数copy_n心得
- javascript 判断是否为数组或对象或各种其它数据类型
- visual studio 2005 / visual studio 2008 添加函数或变量时当前页面的脚本发生错误
- 寻找字符最大公共子串
- 有序集合元素的字符串自然顺序实现
- Linux 中的IPC(三)----work和workqueue
- Misc future 未来即现在?
- 字典树模板
- 【100题】第二十八 整数的二进制表示中1的个数