課程
/后端開發(fā)
/C
/C語言入門
s2的長度應該怎么改
2018-08-03
源自:C語言入門 6-8
正在回答
#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碼這個概念,是以單個字符連續(xù)存放的
? ? 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; ? ?
}
123cws 提問者
舉報
C語言入門視頻教程,帶你進入編程世界的必修課-C語言
1 回答請教各位大佬
2 回答請教各位大佬
2 回答各位大佬請教一下
3 回答請求各位大佬指教
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優(yōu)惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2018-08-03
#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碼這個概念,是以單個字符連續(xù)存放的
? ??
? ? 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; ? ?
}