几个最常用的字符串函数

👁️ 0 人浏览 💬 0 人评论 ❤️ 添加收藏

(本条路线统一用 gcc -std=c11 -O0 -Wall 编译)长度、拷贝、拼接、比较:

#include <stdio.h>
#include <string.h>

int main(void) {
    const char *s = "hello";
    char buf[16];

    strcpy(buf, s);
    strcat(buf, "!");

    printf("%zu/%zu/%d\n", strlen(s), strlen(buf), strcmp(s, "hello") == 0);
    return 0;
}
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论