| | |
how can i get this delete function working pls!!!
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2009
Posts: 38
Reputation:
Solved Threads: 0
i created a delete function to check for similar user id and delete one but it can seems to work, so i need your help please..
C++ Syntax (Toggle Plain Text)
#include<iostream> #include<algorithm> //for std::sort #include<string> using namespace std; struct student { int id; string name; string nationality; string gender; }; void insert(student array[],const unsigned int MAX_STUDENT); bool sortByID(const student& a, const student& b) { return ( a.id < b.id ); } char sortByName(const student& a, const student& b) { return ( a.name < b.name); } char sortByNationality(const student& a, const student& b) { return (a.nationality < b.nationality); } void mySort(student array[],const unsigned int MAX) { int opt = 0; cout<<"Welcome to sorting function please do the following selection"<<endl; cout<<"***************************************************"<<endl; cout<<"* 1.Sort by student ID"<<endl; cout<<"* 2.Sort by student Name"<<endl; cout<<"* 3.Sort by Nationality"<<endl; cout<<"***************************************************"<<endl; cout<<"Selection: "; cin >> opt; cout<<"\n\n"; switch(opt) { case 1: std::sort(array,array+MAX,sortByID); break; case 2: std::sort(array,array+MAX,sortByName); break; case 3: std::sort(array,array+MAX,sortByNationality);break; } } void delete(student array[]); void display(const student array[], unsigned int MAX); int main() { const unsigned int MAX_SIZE = 100; student array[MAX_SIZE]; int option = 0; bool exitProgram = false; do { cout <<"Welcome to student recording system"<<endl; cout <<"Please choose one of the following option\n\n"<<endl; cout <<"1.Insert new record"<<endl; cout <<"2.Sort record"<<endl; cout <<"3.Delete record"<<endl; cout <<"4.Display record"<<endl; cout <<"0) Exit program\n\n\n"; cin >> option; switch(option) { case 1: insert(array,MAX_SIZE); break; case 2: cout<<"you picked sorting\n"; cout<<"Now sorting\n\n\n"; mySort(array,MAX_SIZE); cout<<"Sorting done\n\n\n"; break; case 3: delete(array); break; case 4: display(array,MAX_SIZE); break; default : exitProgram = true; break; } }while(!exitProgram); return 0; } void insert(student array[],const unsigned int MAX_STUDENT) { cout<<"\n\n"; for(unsigned int i = 0 ; i < MAX_STUDENT; i++) { cout<<"For student #"<<(i+1)<<endl<<endl;; cout <<"Enter student ID: "; cin >>array[i].id; cin.ignore(100,'\n'); cout<<endl; cout <<"Enter student name: "; cin >>array[i].name; cin.ignore(100,'\n'); cout<<endl; cout <<"Enter student nationality: "; cin >>array[i].nationality; cin.ignore(100,'\n'); cout<<endl; cout <<"Enter student gender: "; cin >>array[i].gender; cin.ignore(100,'\n'); cout<<endl; } } void display(const student array[], unsigned int MAX) { cout<<"\\************************************************\\"<<endl; for(unsigned int i = 0; i < MAX; i++) { cout<<"---------------------------------------------------"<<endl;; cout<<"Student #:"<<(i+1)<<endl; cout<<"ID# : "<<array[i].id<<endl; cout<<"Name : "<<array[i].name<<endl; cout<<"Nationality : "<<array[i].nationality<<endl; cout<<"Gender : "<<array[i].gender<<endl<<endl; cout<<"---------------------------------------------------"<<endl;; } cout<<"\n\\************************************************\\"<<endl; } void delete(student array[]) { char s2=" "; =" "; strcpy(s1,s2) " " }
First look at the discussion in this thread, which as of this writing is right below yours.
Then write some code, post it, and we'll go from there.
Then write some code, post it, and we'll go from there.
Everyone's gotta believe in something. I believe I'll have another drink.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
•
•
Join Date: Jan 2008
Posts: 3,828
Reputation:
Solved Threads: 501
Also look at all of your other threads on the exact same topic on Daniweb, as well as on other forums. Sometimes people are answering on oher forums at the same time you have them open on Daniweb.
http://www.daniweb.com/forums/thread214624.html
http://www.daniweb.com/forums/thread214486.html
http://www.daniweb.com/forums/thread214440.html
http://www.daniweb.com/forums/thread214101.html
http://www.daniweb.com/forums/thread213808.html
http://www.codeguru.com/forum/showth...hreadid=483563
http://www.cplusplus.com/forum/general/13911/
People spend time giving you help, then you tend not to bother responding and just start a new thread, often not taking the advice in the previous threads and just hoping someone will do the whole thing for you. Other people, not knowing about the other threads, waste time giving the same advice or close to it. And you STILL refuse to ask anything resembling a question in your posts. Just "it doesn't work".
Stop being selfish and wasting other people's time. Show you're willing some effort into this.
http://www.daniweb.com/forums/thread214624.html
http://www.daniweb.com/forums/thread214486.html
http://www.daniweb.com/forums/thread214440.html
http://www.daniweb.com/forums/thread214101.html
http://www.daniweb.com/forums/thread213808.html
http://www.codeguru.com/forum/showth...hreadid=483563
http://www.cplusplus.com/forum/general/13911/
People spend time giving you help, then you tend not to bother responding and just start a new thread, often not taking the advice in the previous threads and just hoping someone will do the whole thing for you. Other people, not knowing about the other threads, waste time giving the same advice or close to it. And you STILL refuse to ask anything resembling a question in your posts. Just "it doesn't work".
Stop being selfish and wasting other people's time. Show you're willing some effort into this.
In this particular thread that VernonDozier posted above:
http://www.daniweb.com/forums/thread214101.html
look at post # 12 by Ancient Dragon where he gives you two possible explanations as to how you could go about creating a delete function. I'm not a betting man, but I'm willing to bet that if you look at either of those suggestions and then try to write your own code and post it here, these guys (myself included, if I can) will be willing to help.
-D
http://www.daniweb.com/forums/thread214101.html
look at post # 12 by Ancient Dragon where he gives you two possible explanations as to how you could go about creating a delete function. I'm not a betting man, but I'm willing to bet that if you look at either of those suggestions and then try to write your own code and post it here, these guys (myself included, if I can) will be willing to help.
-D
![]() |
Similar Threads
- Help with Linked list Delete function (C)
- Delete function for linked list (C++)
- Delete button not working on my Java GUI Inventory (Java)
- print function not working (C++)
- datagrid delete function not auto update (ASP.NET)
- my php session_destroy() function not working (PHP)
Other Threads in the C++ Forum
- Previous Thread: Reading a file into an array
- Next Thread: requiring date validating program
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






