char类型的数组初始化,debug问题
#include <stdio.h>#include <string.h>int main(){ int i; int length; // 给myAlphabets 4个元素,但是调试时,显示的是 // 07 00 00 64 07 00 00 00 // 换成ascii,并不是 a,b,c,d。 // yourAlphabets 的值却是 // 61 62 63 64,ascii码值为a,b,c,d?? char myAlphabets[] = {'a', 'b', 'c', 'd'}; char yourAlphabets[4]; // strlen(myAlphabets)值应该是依平台不同而变化吧? // length = 7,后面的3个元素是怎么来的?? length = strlen(myAlphabets); for (i = 0; i < length; i++) { yourAlphabets[i] = myAlphabets[i]; printf("myAlphabets[%d] is %c\n", i, myAlphabets[i]); } printf("length is %d, sizeof is %d\n", length, sizeof(myAlphabets)); return 0;}