I'm studying pointers in C++ and here is a sample code which I found in a website :
#include <iostream>
#include <iomanip>
using namespace std;
void my_fun (int *p) {
*p = 0;
p++;
*p = 4;
p++;
return;
}
int main ( ) {
int a[3] = {10,20,30};
int *p = a;
cout << *p;
my_fun (p);
cout << setw(5) << a[0] << setw(5) << a[1] << setw(5) << a[2] << setw(5) << *p;
return 0;
}
my expected result is : 10 0 4 30 30
but I got this : 10 0 4 30 0
would you mind please explaining what happens to the last cout ?