Looks like I'll be asking tons of questions in this forum from now Hope I don't make anyone irritated with constant questions.
I'm making my second program for the beginner's C class.. Just that I haven't been able to compile it.
Code:
#include <stdio.h>
#define DISCOUNT 0.00525f;
FILE *fileout;
void main (void)
{
int
item_one,
item_two,
item_three,
subtotal,
disc_amt,
grantotal;
fileout = fopen ("A:REPORT2.RPT","w");
printf ("\n\nPlease enter the amount of the first item: $");
scanf ("%d", &item_one);
printf ("\n\nPlease enter the amount of the second item: $");
scanf ("%d", &item_two);
printf ("\n\nPlease enter the amount of the third item: $:");
scanf ("%d", &item_three);
printf ("\n\nYou have entered these three prices:");
printf ("\n\n First Item: $%d", item_one);
printf ("\n\n First Item: $%d", item_two);
printf ("\n\n First Item: $%d", item_three);
printf ("\n\n Calculating costs...");
printf ("\n\n Receipt created at A:REPORT2.RPT");
subtotal = item_one + item_two + item_three;
disc_amt = subtotal * DISCOUNT;
grantotal = subtotal - disc_amt;
fprintf (fileout, "\n\nCost of first item: $%d", item_one);
fprintf (fileout, "\n\nCost of second item: $%d", item_two);
fprintf (fileout, "\n\nCost of third item: $%d", item_three);
fprintf (fileout, "\n -----------");
fprintf (fileout, "\nTotal Cost $%d", subtotal);
fprintf (fileout, "\nDiscount -$%d", disc_amt);
fprintf (fileout, "\n -----------");
fprintf (fileout, "\nGrand Total $%d", grantotal);
}
Well that's what I have so far.
I get the compiling error at the line "disc_amt = subtotal * DISCOUNT;"
Something like "cannot convert from float/double".
No idea what it means!
Please keep in mind that I'm writing this off a template... the template has just a few lines of coding. To be specific,
#include stuff, FILE * fileout;, void main (void), and fileout = fopen ("A:REPORT2.RPT","w"); are the only things in the template.
From that I have to make everything else in scratch.
Now on to my hideous questions:
1. I've yet to learn what alot of these things are... can anyone tell me what exactly things like
"FILE *fileout;"
"void main (void)"
"fileout = fopen ("A:REPORT2.RPT","w");"
"int" does?
I could pretty much tell what fileout= fopen ... is but i'm not sure what the "w" is for.
As for "int", I'm just assuming I need this to include whatever variables I'm going to put in scanf and formulas.
2. About fprintf, I assume it pretty much works like printf but why would I need a ([B]fileout[\B], "bleh");?
Thanks for reading all this and for having patience with this complete newbie business I have here I appreciate it.