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..

#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)
	      " "
}
Comments
what niek_e said :)
what Vernon said :)
Way too many threads on the same topic. Lack of effort. Inconsiderate of other people's time.

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.

Comments
Indeed
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?
}

Edited 3 Years Ago by happygeek: fixed formatting

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/showthread.php?threadid=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

This question has already been answered. Start a new discussion instead.