As far as I understand, in "int arr[10]", the name of the integer array
"arr"
is equivalent to the pointer to the first element of the array. But is
"arr"
really a pointer, identical as "int *arr;" ?
I tried to modify this "arr" thing in the following code. GCC warns
me of incompatible pointers, which I have no idea of.
---------------------------------------------------------------
#include<stdio. h>
void incrementPtr(in t **);
int main(int argc, char *argv[]){
int i;
int a[3] = {10, 20, 30};
incrementPtr(&a );
for(i = 0; i < 3; i++){
printf("a[%d] = %d\n", i, *(a + i));
}
return 0;
}
void incrementPtr(in t **a){
*a++;
}
-------------------------------------------------
Anyone has any opinion why I got the warning? And
if "a" in this code can be modified?
Thanks.
"arr"
is equivalent to the pointer to the first element of the array. But is
"arr"
really a pointer, identical as "int *arr;" ?
I tried to modify this "arr" thing in the following code. GCC warns
me of incompatible pointers, which I have no idea of.
---------------------------------------------------------------
#include<stdio. h>
void incrementPtr(in t **);
int main(int argc, char *argv[]){
int i;
int a[3] = {10, 20, 30};
incrementPtr(&a );
for(i = 0; i < 3; i++){
printf("a[%d] = %d\n", i, *(a + i));
}
return 0;
}
void incrementPtr(in t **a){
*a++;
}
-------------------------------------------------
Anyone has any opinion why I got the warning? And
if "a" in this code can be modified?
Thanks.
Comment