#include<stdio.h>#include<string.h>void main(){ char b1[8]="abcdefg",b2[8],*pb=b1+3; while(--pb>=b1) strcpy(b2,pb); printf("%d\n",strlen(b2));}
1 回答

停不下的冒險(xiǎn)
TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超2個(gè)贊
結(jié)果為7。
strcpy()是復(fù)制字符串函數(shù)。
最后一次循環(huán)時(shí),*pb=b1,即*pb指向字符串?dāng)?shù)組的首地址。
即將b1[8]全部復(fù)制到b2[]里。
strlen()計(jì)算數(shù)組中的字符(abcdefg)個(gè)數(shù)(長度)。
- 1 回答
- 0 關(guān)注
- 1263 瀏覽
添加回答
舉報(bào)
0/150
提交
取消