代码点读机 / C / string.h

string.h C · 头文件

C 字符串处理库的头文件,包含复制、拼接、比较、求长度等函数。

怎么用

#include <string.h>

小例子

#include <stdio.h>
#include <string.h>
int main(void) {
    char s[20];
    strcpy(s, "hi");
    printf("%s", s);
    return 0;
}

运行结果

输出 hi

提醒:strlen、strcpy、strcmp、strcat、memcpy、memset 等都在这里

官方文档:https://en.cppreference.com/w/c/string

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← C全部词条