it seems your concepts are not clear about pointers, or may be you have copied this code from somewhere else.
one thing I would suggest you, have well understanding of each line of you code when ever you write any program.
Code:
printf ("Please enter ten intergers now. Seperate each number by a space\n");
for ( i = 0; i < 10; i++) {
scanf ("%d", &array1[i]);
}
printf ("Please enter ten intergers now. Seperate each number by a space\n");
for ( i = 0; i < 10; i++) {
scanf ("%d", &array2[i]);
}
alternatively you can also write
Code:
for ( i = 0; i < 10; i++) {
scanf ("%d", (array1+i));
}
make a concept, scanf() function always put the given value at the given address in the given format.
here array1 --- gives the base address of array1. hence scanf() will put the value at this location which finally will be value of first element. and (array1+i) means putting the value at each next location till the array size;
Code:
/*int add1and2 (array3[9]);*/
as according to add1and2() definition, it supposed to pass three arguments like this
add1and2(arr1 , arr2 , arr3);
with this, compiler understand that the base addresses(address of first elements) of arrays are being passed which may further be iterated through its each element.
Code:
int add1and2 (array1[], array2[], array3[])
you should rather write
Code:
int add1and2 (int array1[], int array2[], int array3[])
the formal arguments need to be defined fully;
Code:
int *point2a1 = &array1[];
int *point2a2 = &array2[];
int *point2a3 = &array3[];
applying subscript operator only means you are assigning the address of unknown entity.
you should rather write
Code:
int *point2a1 = &array1[0];
or
Code:
int *point2a1 =array1;
Code:
for(i = 0; i < 10; i++,) {
array3[i] = *point2a1[i] + *point2a2[i];
}
you code is write though, however it doesn't make any sense if you dont understand what you have written;
Code:
array3[i] = *point2a1[i] + *point2a2[i];
can be understood as
Code:
*(array3+i) = *(*(point2a1+i)) + *(*(point2a1+i)) ;
means, you are pointing to the same value two times using * operator. although this is not a error prone but it is senseless too.