Forward Values from one function to another
I'm having a problem here, whereby i can link the structure array values to another function from Pumppetrol() to FuelReport()
I need to bring over the data of the Super, Diesel and V-power and the amount entered as well..
Please help:(
I'm stuck!!:(
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#include "displaymenu.cpp"
#define size 5
#include<iostream>
using namespace std;
struct Fuel{
char fuel_type;
float fuel_amount;
float Litre;
};
void PumpPetrol(struct Fuel []);
void FuelReport(struct Fuel []);
int main(){
int choice;
char option='y';
Fuel fuel[size];
//fuel_amount fuel[10];
//Litre fuel[10];
do{
system("cls");
displaymenu();
cin>>choice;
switch(choice)
{
case 1: PumpPetrol(fuel);
break;
case 2: FuelReport(fuel);
break;
case 3: //DispenserReport();
break;
case 4: //SummaryReport();
break;
case 5: cout<<"Thanks for using the sytem";
break;
default: cout<<"Invalid";
break;
}
cout<<"Do you want to continue? [Y/N] :";
cin>>option;
} while (option =='y'||option =='Y');
cout<<"Thank you";
system("pause");
}
void PumpPetrol(struct Fuel f[size]){
system("cls");
for (int i=0;i<=size;i++){
cout<<"Enter Fuel type(S=Super,V=V-Power,D=Diesel:";
cin>>f[i].fuel_type;
cout<<"Enter Fuel amount:";
cin>>f[i].fuel_amount;
switch (f[i].fuel_type)
{
case's':case'S':
cout<<"Super";
f[i].Litre=f[i].fuel_amount*100/188;
cout<<"Amount:"<<f[i].fuel_amount<<endl;
cout<<"Litre:"<<f[i].Litre<<endl;
break;
case'v':case'V':
cout<<"V-Power";
f[i].Litre=f[i].fuel_amount*100/192;
cout<<"Amount:"<<f[i].fuel_amount<<endl;
cout<<"Litre:"<<f[i].Litre<<endl;
break;
case'd':case'D':
cout<<"Diesel";
f[i].Litre=f[i].fuel_amount*100/158;
cout<<"Amount:"<<f[i].fuel_amount<<endl;
cout<<"Litre:"<<f[i].Litre<<endl;
break;
default:
cout<<"Invalid";
break;
}}}
void FuelReport(struct Fuel f[size]){
cout<<"amount:"<<f[i].fuel_amount;
}
|
I'm using DeV C++ complier and the errors are:
LINE 91 - `i' undeclared (first use this function)
In function `void FuelReport(Fuel*)':
Actually the i have been declared on earlier Pumppetrol() fucntion.
Please help. Very much appreciated
first you dont include .cpp files. you link them through .h files and you didnt declare i in the function so how can it know what i is?
great aramil of elixia
Topic archived. No new replies allowed.