1. 程式人生 > >字串和字元數值的區別(sizeof)

字串和字元數值的區別(sizeof)

#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
char x[]="abcdefg";
char y[]={'a','b','c','d','e','f','g'};
int xlen;
int ylen;
xlen=sizeof(x);
ylen=sizeof(y);
printf("xlen=%d ylen =%d\n",xlen,ylen);
return 0;
}

xlen=8 ylen =7