課程
/后端開發(fā)
/C
/C語言入門
s2的長度應(yīng)該怎么改
2018-08-03
源自:C語言入門 6-8
正在回答
#include <stdio.h>
#include <string.h>
#define s4 "ab"
int main()
{
? ? char s1[100]="";
? ? char s2[]="我愛,";
? ? char s3[]="慕課網(wǎng)";
? ? /*在以下補(bǔ)全代碼*/
? ? strcpy(s1,s2);
? ? strcat(s1,s3);
? ? printf("s1=%s\n",s1);
? ??
? ? //字符串沒有ASCLL碼這個(gè)概念,是以單個(gè)字符連續(xù)存放的
? ? printf("字符串長度:%d\n",strlen(s1));
? ? printf("字符串s2=%s s3=%s\n",s2,s3);
? ? printf("字符串s1,s2比較結(jié)果:%d\n",strcmp(s2,s3));
? ? printf("字符串a(chǎn)的ASCLL碼:%d, b的ASCLL碼:%d;a,b比較結(jié)果:%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=慕課網(wǎng)
? ? 字符串s1,s2比較結(jié)果:3
? ? 字符串a(chǎn)的ASCLL碼4196523,b的ASCLL碼4196521;a,b比較結(jié)果:-1
? ? 字符a的ASCLL碼97,b的ASCLL碼98
? ? 字符串s4:4196629
? ? 字符串s4:ab
? ? */
? ? return 0; ? ?
}
123cws 提問者
舉報(bào)
C語言入門視頻教程,帶你進(jìn)入編程世界的必修課-C語言
1 回答請教各位大佬
2 回答請教各位大佬
3 回答請求各位大佬指教
2 回答各位大佬請教一下
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2018-08-03
#include <stdio.h>
#include <string.h>
#define s4 "ab"
int main()
{
? ? char s1[100]="";
? ? char s2[]="我愛,";
? ? char s3[]="慕課網(wǎng)";
? ? /*在以下補(bǔ)全代碼*/
? ? strcpy(s1,s2);
? ? strcat(s1,s3);
? ? printf("s1=%s\n",s1);
? ??
? ? //字符串沒有ASCLL碼這個(gè)概念,是以單個(gè)字符連續(xù)存放的
? ??
? ? printf("字符串長度:%d\n",strlen(s1));
? ? printf("字符串s2=%s s3=%s\n",s2,s3);
? ? printf("字符串s1,s2比較結(jié)果:%d\n",strcmp(s2,s3));
? ? printf("字符串a(chǎn)的ASCLL碼:%d, b的ASCLL碼:%d;a,b比較結(jié)果:%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=慕課網(wǎng)
? ? 字符串s1,s2比較結(jié)果:3
? ? 字符串a(chǎn)的ASCLL碼4196523,b的ASCLL碼4196521;a,b比較結(jié)果:-1
? ? 字符a的ASCLL碼97,b的ASCLL碼98
? ? 字符串s4:4196629
? ? 字符串s4:ab
? ? */
? ? return 0; ? ?
}