accessing arrays with pointers
Hi all! I am new here, and I am also new to C language... I just had a few classes in Fortran and also know some Unix basics, but none of these seem to help me at the moment.
I have to write a function which will calculate a sum of all the elements in an array[5], but I have to do it using pointers to access these elements.... I feel so confused about it all. Can you help me get through this?
:confused:
I thought that this would be a way out, but there are no pointers there.
/code/:
Code:
int sum_array(int array[], int total_sum)
{
int i;
for (i=0; i<=5; i++)
total_sum += array[ i ]; // There are really no spaces around the i but it makes it italics here - Done by Kermi3
}
Even when I tried this, the compiler (Visual Studio) said there is an error....
Can you help, please?
Thanks...
Code tags added by Kermi3, good attempt on it....see http://www.cprogramming.com/cboard/s...threadid=13473 to get it right next time or PM me