为了账号安全,请及时绑定邮箱和手机立即绑定

请教各位大佬

https://img1.sycdn.imooc.com//5b63cadc0001a27802940325.jpgs2的长度应该怎么改

正在回答

1 回答

#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;    

}


0 回复 有任何疑惑可以回复我~
#1

123cws 提问者

非常感谢!
2018-08-03 回复 有任何疑惑可以回复我~
#2

123cws 提问者

为什么字符串s1,s2比较结果,后面却是strcmp(s2,s3)?
2018-08-03 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
C语言入门
  • 参与学习       924451    人
  • 解答问题       20757    个

C语言入门视频教程,带你进入编程世界的必修课-C语言

进入课程

请教各位大佬

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信