c编程中关于字符串的函数编写
来源:互联网 发布:h5简单的js小游戏 编辑:程序博客网 时间:2024/05/16 00:39
/ c.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <stdio.h>
//对字符串进行操作的时候,要注意是否越界!这里没有检查
unsigned int strlen(const char *source)
{ //the strlen doesn't include the "/0"
unsigned int i=0;
while(source[i])
i++;
return i;
}
char *strcpy(char *destination,const char *source)
{ //copy source string to destination string
char *original=destination;
while (*destination++ = *source++ )
; //important void sentence
return original;
}char *strcat(char *target,const char *source)
{
char *original=target;
while (*target++)
;
target--; //pay attention to the targer point the position of the string!
while (*target++ = *source++)
;
return original;
}
//测试函数
int _tmain(int argc, _TCHAR* argv[])
{
char str1[100]="/0";
char str2[]="hello,string!";
printf("the length of the str1 is %d /n",strlen(str1));
printf("the length of the str1 is %d /n",strlen(str2));
printf("the str1 which copyed from str2 is %s /n",strcpy(str1,str2));
printf("str1+str2 is %s /n",strcat(str1,str2));
getchar();//暂停程序
return 0;
}
- c编程中关于字符串的函数编写
- 编写关于字符串的几个常用函数
- C语言:编写从一个字符串中提取一个子字符串的函数my_substr
- C中关于字符串和字符的处理函数
- 关于字符串中函数的实现( C语言 )
- C语言中关于字符串的一些常用函数
- 关于C中字符/字符串输入函数的讨论
- 关于《程序员编程宝典》中编写一个函数,作用是把一个char组成的字符串循环右移n位的问题
- C语言:关于字符串的编程题
- 编程c++dll , DLL 的编写,导出函数 ,使用函数
- 程序员编程艺术---4、常用字符串函数的编写
- 编写程序时关于字符串时的一些主要函数
- 关于C语言字符串函数的思考
- 关于C语言字符串函数的思考
- C语言自己编写的字符串操作的函数
- 138。编写一个 C 函数,该函数在一个字符串中找到可能的最长的子字符串,且该字符串是由同一字符组成的。
- C语言 一个字符串翻转函数的编写
- 自己编写c语言实现的字符串操作函数
- VTK居然不支持纹理读入
- SQL2000里的数据类型
- VC++6.0中编写Unicode编码的应用程序
- 一个递归小函数,用于组合树控件的文本
- Iron Python连接数据库的测试
- c编程中关于字符串的函数编写
- 用 vectors 改进内存的再分配
- .Net PetShop 4.0的缓存处理
- 再谈“在STL列表(Lists)中插入不同类型的对象”
- 狂逛水区
- 使用::std::vector作为管理动态数组的优先选择
- ROBOCOPY
- 用函数模板实现和优化抽象操作
- 余姓家谱文献