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: xfreebornx has a little shameless behaviour in the past 
Solved Threads: 0
xfreebornx xfreebornx is offline Offline
Light Poster

how can i get this delete function working pls!!!

 
-3
  #1
Sep 2nd, 2009
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..

  1. #include<iostream>
  2. #include<algorithm> //for std::sort
  3. #include<string>
  4.  
  5. using namespace std;
  6.  
  7. struct student
  8. {
  9. int id;
  10. string name;
  11. string nationality;
  12. string gender;
  13. };
  14.  
  15. void insert(student array[],const unsigned int MAX_STUDENT);
  16.  
  17. bool sortByID(const student& a, const student& b)
  18. {
  19. return ( a.id < b.id );
  20. }
  21.  
  22.  
  23. char sortByName(const student& a, const student& b)
  24. {
  25. return ( a.name < b.name);
  26. }
  27.  
  28. char sortByNationality(const student& a, const student& b)
  29. {
  30. return (a.nationality < b.nationality);
  31. }
  32.  
  33. void mySort(student array[],const unsigned int MAX)
  34. {
  35. int opt = 0;
  36. cout<<"Welcome to sorting function please do the following selection"<<endl;
  37. cout<<"***************************************************"<<endl;
  38. cout<<"* 1.Sort by student ID"<<endl;
  39. cout<<"* 2.Sort by student Name"<<endl;
  40. cout<<"* 3.Sort by Nationality"<<endl;
  41. cout<<"***************************************************"<<endl;
  42. cout<<"Selection: ";
  43. cin >> opt;
  44. cout<<"\n\n";
  45.  
  46. switch(opt)
  47. {
  48. case 1: std::sort(array,array+MAX,sortByID); break;
  49. case 2: std::sort(array,array+MAX,sortByName); break;
  50. case 3: std::sort(array,array+MAX,sortByNationality);break;
  51. }
  52.  
  53. }
  54. void delete(student array[]);
  55. void display(const student array[], unsigned int MAX);
  56. int main()
  57. {
  58. const unsigned int MAX_SIZE = 100;
  59. student array[MAX_SIZE];
  60.  
  61. int option = 0;
  62. bool exitProgram = false;
  63.  
  64. do
  65. {
  66. cout <<"Welcome to student recording system"<<endl;
  67. cout <<"Please choose one of the following option\n\n"<<endl;
  68. cout <<"1.Insert new record"<<endl;
  69. cout <<"2.Sort record"<<endl;
  70. cout <<"3.Delete record"<<endl;
  71. cout <<"4.Display record"<<endl;
  72. cout <<"0) Exit program\n\n\n";
  73.  
  74. cin >> option;
  75.  
  76. switch(option)
  77. {
  78. case 1: insert(array,MAX_SIZE); break;
  79.  
  80. case 2: cout<<"you picked sorting\n";
  81. cout<<"Now sorting\n\n\n";
  82. mySort(array,MAX_SIZE);
  83. cout<<"Sorting done\n\n\n";
  84. break;
  85.  
  86. case 3: delete(array); break;
  87. case 4: display(array,MAX_SIZE); break;
  88.  
  89. default : exitProgram = true; break;
  90. }
  91.  
  92. }while(!exitProgram);
  93.  
  94.  
  95. return 0;
  96.  
  97. }
  98. void insert(student array[],const unsigned int MAX_STUDENT)
  99. {
  100.  
  101. cout<<"\n\n";
  102.  
  103. for(unsigned int i = 0 ; i < MAX_STUDENT; i++)
  104. {
  105.  
  106. cout<<"For student #"<<(i+1)<<endl<<endl;;
  107. cout <<"Enter student ID: ";
  108. cin >>array[i].id;
  109. cin.ignore(100,'\n');
  110. cout<<endl;
  111.  
  112. cout <<"Enter student name: ";
  113. cin >>array[i].name;
  114. cin.ignore(100,'\n');
  115. cout<<endl;
  116.  
  117. cout <<"Enter student nationality: ";
  118. cin >>array[i].nationality;
  119. cin.ignore(100,'\n');
  120. cout<<endl;
  121.  
  122. cout <<"Enter student gender: ";
  123. cin >>array[i].gender;
  124. cin.ignore(100,'\n');
  125. cout<<endl;
  126. }
  127. }
  128.  
  129. void display(const student array[], unsigned int MAX)
  130. {
  131. cout<<"\\************************************************\\"<<endl;
  132. for(unsigned int i = 0; i < MAX; i++)
  133. {
  134. cout<<"---------------------------------------------------"<<endl;;
  135. cout<<"Student #:"<<(i+1)<<endl;
  136. cout<<"ID# : "<<array[i].id<<endl;
  137. cout<<"Name : "<<array[i].name<<endl;
  138. cout<<"Nationality : "<<array[i].nationality<<endl;
  139. cout<<"Gender : "<<array[i].gender<<endl<<endl;
  140. cout<<"---------------------------------------------------"<<endl;;
  141.  
  142. }
  143. cout<<"\n\\************************************************\\"<<endl;
  144. }
  145.  
  146. void delete(student array[])
  147. {
  148. char s2=" ";
  149. =" ";
  150. strcpy(s1,s2)
  151. " "
  152. }
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 311
Reputation: NicAx64 will become famous soon enough NicAx64 will become famous soon enough 
Solved Threads: 18
NicAx64's Avatar
NicAx64 NicAx64 is offline Offline
Posting Whiz

Re: how can i get this delete function working pls!!!

 
1
  #2
Sep 2nd, 2009
delete is a C++ keyword so use a different identifier other than
delete.

and also use the delete keyword to delete the arrays that you no
longer using. ( I mean inside that function ). Otherwise you will
get memory leaks.
Nothing like a kernel pannic !
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 2
Reputation: emirpp is an unknown quantity at this point 
Solved Threads: 1
emirpp emirpp is offline Offline
Newbie Poster

Re: how can i get this delete function working pls!!!

 
0
  #3
Sep 4th, 2009
void delete(student array[]) --> change function name
{
char s2=" ";
=" "; --> is it s1 declared here?
strcpy(s1,s2)-->> what its mean copying null to null??
" " -->>>what is this means?
}
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 1,679
Reputation: vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold 
Solved Threads: 193
vmanes's Avatar
vmanes vmanes is offline Offline
Posting Virtuoso

Re: how can i get this delete function working pls!!!

 
0
  #4
Sep 4th, 2009
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.
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,828
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: how can i get this delete function working pls!!!

 
0
  #5
Sep 4th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 73
Reputation: dgr231 is on a distinguished road 
Solved Threads: 7
dgr231's Avatar
dgr231 dgr231 is offline Offline
Junior Poster in Training

Re: how can i get this delete function working pls!!!

 
0
  #6
Sep 4th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 38
Reputation: xfreebornx has a little shameless behaviour in the past 
Solved Threads: 0
xfreebornx xfreebornx is offline Offline
Light Poster

Re: how can i get this delete function working pls!!!

 
0
  #7
Sep 4th, 2009
okay guys tnx for all ur comments i appreciate!!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC