fork download
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char* argv[])
  4. {
  5. char *a ="12345";
  6. char s[] ="12345";
  7. char S[10];
  8. /* S = "12345" Sは配列の先頭要素のアドレスを指すだけなので代入できない*/
  9. S[0] = '1';
  10. S[1] = '2';
  11. S[2] = '3';
  12. S[3] = '4';
  13. S[4] = '5';
  14. S[5] = '\0';
  15.  
  16. printf("%p\n",a);
  17. printf("%p\n",s);
  18.  
  19. printf("%p :%c\n",&a[0],a[0]);
  20. printf("%p :%c\n",&a[1],a[1]);
  21. printf("%p :%c\n",&a[2],a[2]);
  22. printf("%p :%c\n",&a[3],a[3]);
  23. printf("%p :%c\n",&a[4],a[4]);
  24.  
  25. printf("%p :%c\n",&s[0],s[0]);
  26. printf("%p :%c\n",&s[1],s[1]);
  27. printf("%p :%c\n",&s[2],s[2]);
  28. printf("%p :%c\n",&s[3],s[3]);
  29. printf("%p :%c\n",&s[4],s[4]);
  30.  
  31. printf("%p :%s\n",S,S);
  32. printf("%p :%c\n",&S[0],S[0]);
  33.  
  34. return 0;
  35.  
  36. }
Success #stdin #stdout 0.02s 1676KB
stdin
Standard input is empty
stdout
0x8048740
0xbfdd933e
0x8048740 :1
0x8048741 :2
0x8048742 :3
0x8048743 :4
0x8048744 :5
0xbfdd933e :1
0xbfdd933f :2
0xbfdd9340 :3
0xbfdd9341 :4
0xbfdd9342 :5
0xbfdd9334 :12345
0xbfdd9334 :1