Home Common Problem What header file is string.h?

What header file is string.h?

Jun 03, 2019 pm 03:35 PM

string.h is a commonly used header file in the C language standard library, which is needed when using character arrays.

What header file is string.h?

string.h is widely used in both c language and c language, but the specific situations are not quite the same. Since traditional C was born out of C, the usage of this term in traditional C is similar to that in C language. In standard C, which has been modified and standardized by the American Standardization Organization, the definition is quite different.

The functions and differences between string and string.h in c

Answer: Generally in C libraries, for an old one, that is, with ".h" For library files with extensions (such as iostream.h), there is a corresponding one without the ".h" extension in the standard library after the new standard. In addition to the many improvements of the latter, there is another difference. The latter stuff is stuffed into the "std" namespace.

But only string is special.

Recommended course: C Language Tutorial.

The problem is that C needs to be compatible with the C standard library, and the C standard library happens to already have a header file named "string.h", which contains some commonly used C string processing functions.

This header file has nothing to do with C's string class, so is not an "upgraded version" of . They are two header files that have nothing to do with each other.

c What functions are included in ?

Answer: Commonly used functions are as follows:

strlen finds the length of a string

strcmp compares two strings to see if they are the same

strcat string connection Operation

strcpy string copy operation

strncat string connection operation (first n characters)

strncpy string copy operation (first n characters)

strchr query string

strstr Query substring function usage

The following is the detailed usage of the function in the string.h file, with additional examples:

strcpy

Function name: strcpy

Function: Copy one string to another

Usage: char *strcpy(char *destin, char *source);

Program example:

#include<stdio.h>
#include<string.h>
int main(void)
{
char string[10];
char*str1="abcdefghi";
strcpy(string,str1);
printf("%s\n",string);
return 0;
Copy after login

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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1248
24