I'm learning the basic knowledge of c programming language. And now I am confused at pointer sections. There is the original question in the book:
Array a has some value and pointer p is now at a[1]:
a[0]:10
a[1]:20 <---p
a[2]:30
a[3]:40
a[4]:50
Question List:
- What's the value of
*pafter executes* p++? - What's the value of
* ++p? - What's the value of
++ * p?
So, What's the different between *p++, * ++p, ++*p?
In my opinion:
*p++means to move pointerppoints the next element, so the 1st answer is 30.- The difference of
*p++and*++pjust like the difference ofi++and++i. so the 2nd answer is 30. *pmeans the value of pointer p, so++*pmeans to letpvalue increase 1. So the 3rd answer is 21;
Am i right?