Jul 10, 2013 at 7:47am UTC
errors with program
#include <iostream>
#include <fstream>
using namespace std;
void displayitens();
int getwhattheywant(int d);
int main() {
int whattheywant;
whattheywant = getwhattheywant();
while(whattheywant != 4){
switch(whattheywant){
case 1:
displayitems(1);
break;
case 2:
displayitems(2);
break;
case 3:
displayitems(3);
break;
}
whattheywant = getwhattheywant();
}
}
int getwhattheywant(){
int choice;
cout <<"1 for plain items" << endl;
cout <<"2 for helpful items" << endl;
cout <<"3 for harmfull items" << endl;
cout <<"4 to exit" << endl;
cin >> choice;
return choice;
}
void displayitens(int d)
{
ifstream objectfile("objects.text");
string oname;
double opower;
if(d==1){
while(objectfile >> oname >> opower){
if(opower==0){
cout << oname << ' ' << opower << endl;
}
}
}
if(d==2){
while(objectfile >> oname >> opower){
if(opower>0){
cout << oname << ' ' << opower << endl;
}
}
}
if(d==3){
while(objectfile >> oname >> opower){
if(opower<0){
cout << oname << ' ' << opower << endl;
}
}
}
}
Jul 10, 2013 at 8:19am UTC
Use the code tags. Also, I'm not searching through all that to figure out what's wrong. Give some info. What are you trying to do? Is it a compile error that you're running into? What's wrong with it? That info helps pinpoint the cause of the problem.
Jul 10, 2013 at 8:20am UTC
You call the function for displaying items displayitens, but you're calling displayitems (typo?)
Jul 10, 2013 at 8:23am UTC
thanku mannude that was it and also cool name