whats wrong with my code

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;
}
}
}
}

closed account (1wU9216C)
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.
You call the function for displaying items displayitens, but you're calling displayitems (typo?)
thanku mannude that was it and also cool name
Topic archived. No new replies allowed.