Hi I'm new to this so be nice. I have written a function to print all the elements of an array. But currently it is printing the wrong values.
here is part of my code:
I hope you can help thanks.Code:void printarray(double *p,int l){ unsigned short int i; for (i=0; i<l; i++) { printf("%d\n",*p); p++; } } int main() { double U,V,positions[6],distances[4],masses[2],F[4],*pdistances,*pF,*ppositions; const double G=6.673e-11; //inputs printf("what is the x -co-ordinate of p1 in m\n"); scanf("%lf",positions[0]); printf("what is the y -co-ordinate of p1 in m\n"); scanf("%lf",positions[1]); printf("what is the z -co-ordinate of p1 in m\n"); scanf("%lf",positions[2]); printf("what is the x -co-ordinate of p2 in m\n"); scanf("%lf",positions[3]); printf("what is the y -co-ordinate of p2 in m\n"); scanf("%lf",positions[4]); printf("what is the z -co-ordinate of p2 in m\n"); scanf("%lf",positions[5]); ppositions=positions; printarray(ppositions,6); return 0; }



LinkBack URL
About LinkBacks
. I have written a function to print all the elements of an array. But currently it is printing the wrong values.


