Nov 10, 2011 at 10:09pm UTC
Is holders
of type "eggSuckingZombie"? You can't use >>
on an eggSuckingZombie type.
As it is, your code makes no sense. The user enters a value for the variable holders
, and the very next thing you do is change that value again, so there was no point at all in the user entering anything.
Last edited on Nov 10, 2011 at 10:11pm UTC
Nov 11, 2011 at 12:35am UTC
I am trying to let the user change the value they wanted. So i need to change. I tried using getline (cin, ..) but it gives me the same weird answer:
STRUCTURES.cpp 'struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >' has no member named 'name'
my full code of the function is :
please help
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
struct student
{
string name;
int grade;
string gender;
int studentnumber;
string medperil;
string address;
int telephone;
} ;
void displayer(string array[])
{
int m, input;
string ans;
int holder;
string holders;
cout << "Do you want to change anything. y/n" << endl;
cin >> ans;
while (ans == "y" || ans == "Y" )
{
cout << "Please say the position of the student you would like to change" << endl;
cin >> m;
cout << "what would you like to change?" << endl;
cout << " 1) Name" << endl;
cout << " 2) Grade" << endl;
cout << " 3) Gender" << endl;
cout << " 4) Studentnumber" << endl;
cout << " 5) Medperil" << endl;
cout << " 6) Address" << endl;
cout << " 7) Phone" << endl;
cin >> input;
if (input ==1)
{
cout << "what would you like to change it to?" << endl;
cin >> holders;
holders = array[m].name;
}
else if (input == 2)
{
cout << "what would you like to change it to?" << endl;
cin >> holder;
holder = array[m].grade;
}
else if (input == 3)
{
cout << "what would you like to change it to?" << endl;
cin >> holders;
holders= array[m].gender;
}
else if (input ==4)
{
cout << "what would you like to change it to?" << endl;
cin >> holder ;
holder = array[m].studentnumber ;
}
else if (input ==5)
{
cout << "what would you like to change it to?" << endl;
cin >> holders ;
holders= array[m].medperil ;
}
else if (input ==6)
{
cout << "what would you like to change it to?" << endl;
cin >> holders ;
holders= array[m].address ;
}
else if (input ==7)
{
cout << "what would you like to change it to?" << endl;
cin >> holder;
holder = array[m].telephone ;
}
else
{
cout << "Nothing to change" << endl;
}
cout << "Do you want to change anything. y/n" << endl;
cin >> ans;
}
}
Last edited on Nov 11, 2011 at 12:46am UTC
Nov 13, 2011 at 3:54am UTC
because holder is the user's input that you want to use to change array[m].whatever you should not assign array[m].whatever to holder. instead reverse that code so that you are assigning holder to array[m].whatever . as moschops was trying to point out to you. hope you find this helpful.