출처 http://c-faq.com

Q: Does *p++ increment p, or what it points to?

   

A: The postfix ++ and -- operators essentially have higher precedence than the prefix unary operators. Therefore, *p++ is equivalent to *(p++); it increments p, and returns the value which p pointed to before p was incremented. To increment the value pointed to by p, use (*p)++ (or perhaps ++*p, if the evaluation order of the side effect doesn't matter).

References: K&R1 Sec. 5.1 p. 91

K&R2 Sec. 5.1 p. 95

ISO Sec. 6.3.2, Sec. 6.3.3

H&S Sec. 7.4.4 pp. 192-3, Sec. 7.5 p. 193, Secs. 7.5.7,7.5.8 pp. 199-200

'Language > C' 카테고리의 다른 글

msgsnd/ msgrcv 함수 예제  (0) 2012.07.12
C FAQ (포인터 증가 2)  (0) 2012.07.12
C FAQ (포인터 증가에 대해서)  (0) 2012.07.12
C-FAQ 어찌되었건 pointer 쓰면 정말 좋은가?  (0) 2012.07.12
C FAQ (malloc 오류)  (0) 2012.07.12
C FAQ (포인터 선언 에러)  (0) 2012.07.12

+ Recent posts