Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help passing in a variable....

Status
Not open for further replies.

bgreen

Programmer
Feb 20, 2003
185
CA
I want to be able to pass in the variable diff into the fprintf statement where the number 87 is. How do I do this?

diff = dollar - cent;

POS(.25);
fprintf(fd, "%.87s --\r\n", cheque.sp_amount);
 
Code:
fprintf (fd, "%.2f -- \n", diff);
Not sure what the other bits of your pseudo code are
 
I want to pass in diff where the 87 is. I need to keep the %s in for the cheque spelling amount.

ex.

fprintf(fd, "%.%ds --\r\n", diff, cheque.sp_amount);

%d = 87
 
Almost right
Code:
fprintf(fd, "%.2f %s  --\r\n", diff, cheque.sp_amount);
Assuming diff is a float. Alternatively
Code:
fprintf(fd, "%d %s  --\r\n", diff, cheque.sp_amount);
if diff is an integer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top