[try Beta version]
Not logged in

 
whats wrong with my code

Jul 10, 2013 at 7:47am
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
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.
Jul 10, 2013 at 8:20am
You call the function for displaying items displayitens, but you're calling displayitems (typo?)
Jul 10, 2013 at 8:23am
thanku mannude that was it and also cool name
Topic archived. No new replies allowed.