0
点赞
收藏
分享

微信扫一扫

算法训练营 训练 1- 45(C语言实现)

JakietYu 2022-01-24 阅读 36

输入一些字符串,对其进行复制、拼接、比较等操作。

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

int main(void) {
    char s1[100];
    char s2[20] = "Hello";
    scanf("%s",&s1);
    printf("%d\n", strlen(s1));
    strncat(s1,s2,100);
    strncat(s1,"abc",4);
    printf("%s\n",s1);
    printf("%d\n",strcmp(s1,s2));
    printf("%p\n",strstr(s1,s2));
    strncpy(s1,s2,100);
    printf("%s\n",s1);
    printf("%p\n",strchr(s1,'l'));
    printf("%p\n",strrchr(s1,'l'));
    printf("%s\n",tolower(s1));
    printf("%s\n",toupper(s1));
    return 0;
}

输入:

app

输出:

app
3
appHelloabc
1
000000fcbbfff693
Hello
000000fcbbfff692
000000fcbbfff693
举报

相关推荐

0 条评论