Passing by value and printing in function
I have an assignment I am working on, I am stuck at a beggining point. Below is the code I am working with. This is pretty much what the professor gave us to start with, all I am trying to do right now is pass some values to the subroutine and then print them in the subroutine to confirm the values passed. We have to pass by value. I can print the values in the main fine, but then I always get zeroes in the subroutine. I have a lot more to do in the assignment, but have been stuck here. Any help would be greatly appreciated.
unsigned long adddouble(unsigned long x, unsigned long y)
printf("%ld %ld \n", x, y);
return(x+y); /* no interest at this time */
double d1, d2, *dp;
unsigned long *longp1,*longp2, s;
scanf("%lf %lf", &d1, &d2); /* get two input real numbers */
printf("%lf %lf \n", d1, d2);
longp1 = (unsigned long *) &d1;
longp2 = (unsigned long *) &d2;
s = adddouble(*longp1,*longp2);
Pass adddouble() doubles d1 and d2 and return a double....
Last edited by Scarlet7; 03-17-2003 at 05:19 AM.