What are string processing functions?

藏色散人
Release: 2020-05-07 10:59:38
Original
4053 people have browsed it

What are string processing functions?

What is the string processing function?

String processing function (String processing function) is also called string processing function, which refers to the function used for string processing in programming languages, such as character processing in C, pascal, Visual and LotusScript. Functions for string copying, length calculation, character search, etc.

c

strcpy

Prototype: extern char *strcpy(char *dest,char *src);

Usage:# include

Function: Copy the NUL-terminated string pointed to by src to the array pointed by dest.

Returns a pointer to the character (NUL) at the end of dest.

Example:

// 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;
}
Copy after login

strcat

Prototype: extern char *strcat(char *dest,char *src);

Usage: #include < string.h>

Function: Add the string pointed to by src to the end of dest (overwrite the '\0' at the end of dest) and add '\0'.

Returns the pointer to dest.

Example:

// 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;
}
Copy after login

strlen

Prototype: extern int strlen(char *s);

Usage: #include

Function: Calculate the length of string s

Description: Return the length of s, excluding the terminator NULL.

Example:

// 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;
}
Copy after login

Wait.

Recommended tutorial: c language tutorial

The above is the detailed content of What are string processing functions?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template