×

Loading...

It is not a problem about programming style. I think it is better for you to know the difference. Please try:

int vals[200];
int * ptr;
::memset(vals, '\0', sizeof(int) * 200);
ptr = vals;
*ptr = 10;
cout << "before " << *ptr << endl;
*ptr++ = 20;
cout << "after " << *vals << " " << *ptr <<endl;

Then try:
int vals[200];
int * ptr;
::memset(vals, '\0', sizeof(int) * 200);
ptr = vals;
*ptr = 10;
cout << "before " << *ptr << endl;
*(ptr++) = 20;
cout << "after " << *vals << " " << *ptr <<endl;
Report

Replies, comments and Discussions: