This is GREAT, thanks you a lot.
"Ben" <boningho@gmail.com> wrote in message
news:ey0RUhTfGHA.1264@TK2MSFTNGP05.phx.gbl
How do you increment a pointer to an integer
(increment both the pointer and the content of the pointer)?
How about:
#include <iostream>
using namespace std;
int main()
{
int array[] = {0,1,2,3,4,5,6,7,9};
size_t arraySize = sizeof(array)/sizeof(array[0]);
int *ptr = array;
// display initial array
for(size_t i=0; i<arraySize; ++i)
cout << array[i] << '\n';
cout << "\n\n";
// do the incrementing
while (ptr != array+arraySize )
{
++*ptr;
++ptr;
}
// display modified array
for(size_t i=0; i<arraySize; ++i)
cout << array[i] << '\n';
return 0;
}
--
John Carson