string.h is a commonly used header file in the C language standard library, which is needed when using character arrays.
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
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;
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!