问答详情
源自:6-8 字符串函数

请教各位大佬

https://img.mukewang.com/5b63cadc0001a27802940325.jpgs2的长度应该怎么改

提问者:123cws 2018-08-03 11:24

个回答

  • 慕九州5552665
    2018-08-03 12:47:37
    已采纳

    #include <stdio.h>

    #include <string.h>

    #define s4 "ab"

    int main()

    {

        char s1[100]="";

        char s2[]="我爱,";

        char s3[]="慕课网";

        /*在以下补全代码*/

        strcpy(s1,s2);

        strcat(s1,s3);

        printf("s1=%s\n",s1);

        

        //字符串没有ASCLL码这个概念,是以单个字符连续存放的

        

        printf("字符串长度:%d\n",strlen(s1));

        printf("字符串s2=%s s3=%s\n",s2,s3);

        printf("字符串s1,s2比较结果:%d\n",strcmp(s2,s3));

        printf("字符串a的ASCLL码:%d, b的ASCLL码:%d;a,b比较结果:%d\n","a","b",strcmp("a","b"));

        printf("字符a的ASCLL码%d,b的ASCLL码%d\n",'a','b');

        printf("字符串s4:%d\n",s4);

        printf("字符串s4:%s\n",s4);

        /*

        字符串长度:16

        字符串s2=我爱, s3=慕课网

        字符串s1,s2比较结果:3

        字符串a的ASCLL码4196523,b的ASCLL码4196521;a,b比较结果:-1

        字符a的ASCLL码97,b的ASCLL码98

        字符串s4:4196629

        字符串s4:ab

        */

        return 0;    

    }