atoi、itoa,strcpy,strcmp,memcpy等实现
2012-06-05 15:43
411 查看
1、memcpy、memmove、memset源码
link:http://note.youdao.com/share/?id=1f826e4337c7db272e94fdb4f267a8de&type=note
2、strcpy、strcat等源码
link:http://note.youdao.com/share/?id=d23a598b2e31321517ed57d2599de181&type=note
3、atoi和itoa源码:
link:http://note.youdao.com/share/?id=96b713b249981aa0c5f9be5d0657fb90&type=note
[b]整数字符串的转化[/b]
1、直接采用现有函数
(1)直接采用itoa实现整数到字符串的转换
函数形式为: char *itoa(int value, char *string, int radix);
该函数包含在头文件stdlib.h中。int value 被转换的整数,char *string 转换后储存的字符数组,int radix 转换进制数,如2,8,10,16 进制等。
具体实现为:
View Code
link:http://note.youdao.com/share/?id=1f826e4337c7db272e94fdb4f267a8de&type=note
2、strcpy、strcat等源码
link:http://note.youdao.com/share/?id=d23a598b2e31321517ed57d2599de181&type=note
3、atoi和itoa源码:
link:http://note.youdao.com/share/?id=96b713b249981aa0c5f9be5d0657fb90&type=note
[b]整数字符串的转化[/b]
1、直接采用现有函数
(1)直接采用itoa实现整数到字符串的转换
函数形式为: char *itoa(int value, char *string, int radix);
该函数包含在头文件stdlib.h中。int value 被转换的整数,char *string 转换后储存的字符数组,int radix 转换进制数,如2,8,10,16 进制等。
具体实现为:
View Code
#include<stdio.h> #include<string.h> #define max 100 void main() { int i,len,offset=0,count=1; char str[max]; char temp[max]; printf("please input the string"); scanf("%s",str); len=strlen(str); for(i=0;i<len;i++) { if(str[i+1]==str[i]) { count++; } else { offset+=sprintf(temp+offset,"%c%d",str[i],count); count=1; } } temp[offset]='\0'; printf("the result is: %s",temp); }
相关文章推荐
- atoi itoa strcpy strcmp strlen strcat memcpy memset实现
- memcpy, strcpy, strlen, strcmp, itoa, atoi 的函数实现
- atoi、itoa,strcpy,strcmp,memcpy等实现
- atoi、itoa,strcpy,strcmp,memcpy等实现
- 基础函数的实现(strcpy,strcat, strcmp, atoi, itoa)
- 微软strcpy,strcat和strcmp的实现源代码 itoa atoi
- 实现atoi,itoa,strcmp,strcpy,strcat,strlen函数
- 基础函数的实现(strcpy,strcat, strcmp, atoi, itoa)【转】
- atoi,itoa,strcpy,strcp,memcpy的实现
- 基础函数的实现(strcpy,strcat, strcmp, atoi, itoa)
- 基础函数的实现(strcpy,strcat, strcmp, atoi, itoa)
- 源码:微软strcpy,strcat和strcmp的实现源代码 itoa atoi
- 实现atoi,itoa,strcmp,strcpy,strcat,strlen函数
- 工作的准备:atoi,itoa,strcpy,memcpy,strcmp,二分查找,strcat
- 实现atoi,itoa,strcmp,strcpy,strcat,strlen函数
- 模拟实现函数库中的常用函数,1实现strcpy 2.实现strcat 3.实现strstr 4.实现strchr 5.实现strcmp 6.实现memcpy 7.实现memmove,8实现memset
- 【C语言】str类与men库函数的实现(如:strcpy,strcmp,strstr,strcat,memmove,memcpy)
- 内核源代码实现strcpy,strcmp,memcpy,memove,strcat,strlen,atoi.....
- 实现1.strcpy 2.实现strcat 3.实现strstr 4.实现strchr 5.实现strcmp 6.实现memcpy
- strcpy strlen memcpy strcat strcmp strstr strrev函数的实现代码