字符串处理函数是什么?

字符串函数(String processing function)也叫字符串处理函数,指的是编程语言中用来进行字符串处理的函数,如C,pascal,Visual以及LotusScript中进行字符串拷贝,计算长度,字符查找等的函数。

c

strcpy

原型:extern char *strcpy(char *dest,char *src);

用法:#include <string.h>

功能:把src所指由NUL结束的字符串复制到dest所指的数组中。

返回指向dest结尾处字符(NUL)的指针。

举例:

// strcpy.c
#include <syslib.h>
#include <string.h>
main()
{
char *s="Golden Global View";
char d[20];
clrscr();
strcpy(d,s);
printf("%s",d);
getchar();
return 0;
}

strcat

原型:extern char *strcat(char *dest,char *src);

用法:#include <string.h>

功能:把src所指字符串添加到dest结尾处(覆盖dest结尾处的'\0')并添加'\0'。

返回指向dest的指针。

举例:

// strcat.c
#include <syslib.h>
#include <string.h>
main()
{
char d[20]="Golden Global";
char *s=" View";
clrscr();
strcat(d,s);
printf("%s",d);
getchar();
return 0;
}

strlen

原型:extern int strlen(char *s);

用法:#include <string.h>

功能:计算字符串s的长度

说明:返回s的长度,不包括结束符NULL。

举例:

// strlen.c
#include <syslib.h>
#include <string.h>
main()
{
char *s="Golden Global View";
clrscr();
printf("%s has %d chars",s,strlen(s));
getchar();
return 0;
}

等等。


字符串处理函数是什么