Jump to content

problem with functions and pointer

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
naspek

naspek

    Newbie

  • Members
  • PipPip
  • 10 posts
how to call function? (line 1)
how am i going to print ELIGIBLE or NOT ELIGIBLE(line 3)


 loan_calculate(); //how to call function?
 printf("Monthly payment <RM>:%f", monthly); //i cant print the value
 printf("Status: ", status); //how am i going to print ELIGIBLE or NOT ELIGIBLE
 
 printf("Status: ");

return 0;
}

void loan_calculate (float L, float DP, int Y, float S, float *monthlyPtr, char *statusPtr, float I){

*monthlyPtr = ((L - DP)+((L-DP)*(I/100)*Y))/(12*Y);

if (*monthlyPtr <= ((25/100)*(*monthlyPtr)))
*statusPtr = 'E';

else
*statusPtr = 'N';

return;
}

Edited by Jordan, 03 September 2009 - 07:01 AM.


#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Moved to the correct forum, please don't post questions in the tutorial sections and please use code tags.

#3
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
You need to create variables, assign them values, and pass them in the order specified by the prototype, just like you did with printf().
sudo rm -rf /

#4
veda87

veda87

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
The loan_calculate function takes many arguments
void loan_calculate (float L, float DP, int Y, float S, float *monthlyPtr, char *statusPtr, float I){

but your have called the function with no arguments
loan_calculate();

Didn't the compiler show any error...

#5
veda87

veda87

    Programmer

  • Members
  • PipPipPipPip
  • 126 posts
I guess this is also the continuation of this thread:
http://forum.codecal...function-c.html

So refer this thread for the answers...

#6
ZekeDragon

ZekeDragon

    Writes binary right handed and hex left handed

  • Moderators
  • 2,103 posts
Why do you have to call loan_calculate with no arguments? That's... sloppy. Well the way you'd go about doing it is making a global structure that contains all of that information, then you call the function which gets information from that structure, and then change the structures information accordingly for the remainder of the program. In any serious software application, though, this would be an incredibly bad solution.
Wow I changed my sig!