[질문]-[c] *char 포인터 값에 대해서~
밑에는 제가 테스트해본 결과입니다..
정신없어보이지만..
그중에서 빨간색 부분의 포인터 값이 일반 주소와 틀린데..
그수치가 무엇을 뜻하는지.. 알려주시거나..
도움될만한 자료.. 있으시면.. 도와주세요~
혼자서는.. . 모르겠습니다.~~
<linux@linux.com ~> ./run.exe 1 22 333 4444 5555
============================================================
=== argc=6 argv=./rr,1,22,333,4444,5555
============================================================
===== int ii[]={11,22,33,44,55,66};
&ii[0] ---(0xbfffe570) ii ---(0xbfffe570) &ii ---(0xbfffe570) ii+1 ---(0xbfffe574)
ii[0]+1 d---( 12) ii+1 ---(0xbfffe574) *ii+30 d---( 41)
===== char aa[]="abcdefg";
&aa[0] ---(0xbfffe568) aa ---(0xbfffe568) &aa ---(0xbfffe568) aa+1 ---(0xbfffe569)
aa[0]+1 c---(b) aa s---(abcdefg) *aa-32 c---(A)
&argv 0xbfffe5a4
argv 0xbfffe5e4
&argv[0] 0xbfffe5e4
argv[0] 0xbffffb08 ---> 실제 문자열의 주소다!
argv[0]+1 s값 /rr
*argv[0] c값 .
++argv 0xbfffe5e8
&argv[1] 0xbfffe5e8
argv s값 --->에러
*argv 0xbffffb08
*argv s값 ./rr
argv[0] s값 ./rr
++(*argv) 0xbffffb09
++(*argv) s값 /rr
*argv++ s값 ./rr --->연산자 우선순위는 ++게 높지만 후위연산이라 효력없음
*argv s값 1 --->여기서 효력 나타남
**argv c값 . ---> s는 배열을 읽을라해서 세그먼트에러
**argv+1 c값 /
=============================================================
=== *arr[]={"aaaaa","bbbbb","ccccc","ddddd"}
=============================================================
===== char ca[]="abcdefghijklmn";
&ca[0] ---(0xbfffe540) ca ---(0xbfffe540) &ca ---(0xbfffe540) ca+1 ---(0xbfffe541)
ca[0]+1 d---( 98) ca+1 ---(0xbfffe541) *ca+30 d---( 127)
char *cb="abcdefghijklmn"; puts("===== char *cb=\"abcdefghijklmn\";\n"); printf("&cb[0] ---(%p)\t cb ---(%p)\t &cb ---(%p)\t cb+1 ---(%p)\n",&cb[0],cb,&cb,cb+1); printf("cb[0]+1 d---(%5d)\t\t cb+1 ---(%p)\t *cb+30 d---(%5d)\n\n",cb[0]+1,cb+1,*cb+30);
====== char *cb="abcdefghijklmn";
----------&cb[0] ---( 0x8048ef1) cb ---(0x8048ef1) &cb ---(0xbfffe53c) cb+1 ---(0x8048ef2)
----------cb[0]+1 d---( 98) cb+1 ---(0x8048ef2) *cb+30 d---( 127)
&arr 0xbfffe550
arr 0xbfffe550
&arr[0] 0xbfffe550
arr[0] 0x8048e52
arr[0] s값 aaaaa
&arr[1] 0xbfffe554
arr[1] 0x8048e58
++arr 연산 안됨 배열상수라서
*arr 0x8048e52 --->문자열 16진수 값
*arr s값 aaaaa
*arr+4 0x8048e56
*arr+5 0x8048e57
*arr+5 s값
*arr+6 0x8048e58
*arr+6 s값 bbbbb
**arr s값 ---> 세그오류
**arr c값 a
댓글 달기