As ZuK said earlier, you really shouldn't mix C and C++-style IO. Use cin.get(), not gets(). Incidentally, you should always use fgets() rather than gets(). If you're writing C++, you shouldn't use either of them.
As ZuK said earlier, you really shouldn't mix C and C++-style IO. Use cin.get(), not gets(). Incidentally, you should always use fgets() rather than gets(). If you're writing C++, you shouldn't use either of them.
hi thanks for all the help so far the code i use is just what i was told to do during my c++ course though all corrections have been made a note of so i can use them in the future
another snag though
agein it jumps the switchCode:case 's': { system("cls"); cout<<"search options \n"; cout<<"what would you like to do? \nTo search for full contact details press F \nTo search for addresses press A \nTo search for telephone numbers press T \nTo search for email address press E\nTo search for the members of a politial party press P\nTo quit press Q :- "; cin>> choice2; while(count2 = 0) { choice2 = getchar (); switch(choice2) { case 'F': { tdata.findF(); count2 = 1; break; }
k i tried removing the cin agein but this stops me from being able to type any letter
any ideas
Hint: This is exactly the same problem you were having before.
Also, as a matter of good coding style, you probably shouldn't have any lines of code that are, like, 200 columns long.
this condition is alwais false ( that is assignement that returns 0 )Code:while(count2 = 0)
you want
KurtCode:while(count2 == 0)
k i changed the while but the cin cant be removed do i have to use the cin.ignore agein or am i barking up the wrong tree
I'd think there should only be one input statement ( inside the loop ) either cin >> choice or choice=getchar().
Kurt
k i took out the get char and it worked thanks agein
anotther one
when i call this function it prints out eurika 12 times
it shouldent any ideasCode:void store::findF(void) { int i = 0; bool serch = false; char person[20]; system("cls"); cout << "please enter the name of the person you wish to find their details : "; gets(person); for(i = 0; i < Voters; i++) { if(!strcmp(np[i].name, person)) { cout << "Eurkia \n" << np[i].name << "\n" << np[i].phone << "\n" << np[i].address << "\n" << np[i].email << "\n" << np[i].party ; serch = true; } } if(serch == false) { cout << "Sorry record not found."; } }
ps sorry for keep asking you guys are brilliant mush more help than my tutor
thanks for spending your time on this for me
There's quite a bit wrong with that code: using system("cls"), using gets(), using global variables that really shouldn't be global, spelling the word search "serch", etc.
You should really learn about C++ strings and containers, they would make this job a breeze.
k i understand that my knolage is laking but i only have two days left on this project and i just need to get it working please help