星期三, 8月 23, 2006

char 陣列 指標 問題

char* s1 = "abcde";
char* s2 = "abcde";
char s3[] = "abcde";
char s4[] = "abcde";
char* skk = "abcde";
printf("%p\n", s1);
printf("%p\n", s2);
printf("%p\n", s3);
printf("%p\n", s4);
printf("%p\n", skk);

所得到的
s1
s2
skk位置都會一樣


char aa[64];
cout<<\sizeof(aa)<<\endl; //大小64
\strcpy(aa,"ddd");
cout<<\strlen(aa)<<\endl; 長度3


char*a="~~~~~~~~~~~~";
char a[]="~~~~~~~~~~~~";
printf("%s\n",a);
printf("%s\n",*a); //只會顯示~

Blog E

最好搞清楚一點這小東東

沒有留言: