1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
void add_val(const int * arr, int n)
{
// *arr = -100; // Error!
printf("in ptr's add %p \n", &arr);
printf("in before %p \n", arr);
arr += 1;
printf("in after %p \n", arr);
}
int main()
{
const int arr[] = {1, 2, 3};
printf("out ptr's add %p \n", &arr);
printf("out before %p \n", arr);
add_val(arr,3);
printf("out after %p \n", arr);
}
Enter to Rename, Shift+Enter to Preview