First using intel / XP-Pro / TurboC++4.5 (don't ask me why) / Using a dell D610
I get the concept. I get the usage. I just can not get it to work. I believe the problem is a memory error but can not figure out why.
I kept the code as short as possible (I won't post my entire program unless I need to...
Here's the skinny: this is a gas and go assignment where you input day of week as 0-6, gallons, type of gas (R,U,S), and if you want your car washed. Prices are defined as #define ...
** Not all of code is posted to save space. Besides I want to work through the problem one function at a time...
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include <conio.h>
- //input data function
- void getData (int *dNum, int *gal, char *gType, char *wAns);
- int main(void)
- {
- // DECLARE VARIABLES
- int dayNum, gallons;
- char response, gasType, washAns;
- float unitPrice, washCost, gasCost, total;
- getData(&dayNum, &gallons, &gasType, &washAns); // func call getData
- return 0; // program ran sucessful
- }
- // FUNCTION CALLS
- void getData(int *dNum, int *gal, char *gType, char *wAns)
- {
- clrscr(); // clear screen
- // get day of week
- printf("\nEnter day of the week (0-6)");
- printf("\nSun=0, Mon=1, Tue=2, ..., Sat=6 : ");
- scanf("%d", dNum);
- // get Number Of Gallons Pumped
- printf("\n\nEnter the number of gallons : ");
- scanf("%f", gal);
- // get Type of Gas Purchased
- printf("\n\nEnter gas type");
- printf("\n\(R, U, S or N for no gas\) : ");
- fflush(stdin);
- scanf("%c", gType);
- // get Car Washed?
- printf("\n\nCar Wash \(Y or N\) : ");
- fflush(stdin); //clear buffer for scanf
- scanf("%c", wAns);
- return; // return to calling place
- }