Removing an Array Element

Hello, I am trying to figure out how to remove an element that has been input through the keyboard. I understand that I need to set that element to be the same as the one on the right and then move them all to the left one. However, I'm unsure how to set all of the elements in the struct to be null. Thanks!
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
  void removePlayer(Player list[], int size){
	bool loop = true;
    char name[256];
    system("cls");
	
	if (size < 1) 
	{
		cout << "Nothing to show" << endl;
	} else
	{
	cout << "What Player do you want to remove? (Case sensitive)" << endl;
    cin.getline(name, 256);
	
	  for(int i = 0; i < size; i++)
	  {
		while (name == list[i].name)
		{
			for (int i = 0; i < size; i++)
			{  
				list[i] = list[i+1];
				list[size - 1].name = 0;	
				list[size - 1].team = 0;	
				list[size - 1].goal = 0;	
				list[size - 1].assist = 0;	
				list[size - 1].points = 0;		
    	    }
        
        while (name == false)
		{
			cout << "That player is not in the records!"; break;
    	}
      } 
	system("pause");
	system("cls");	   
    }


The struct is

1
2
3
4
5
6
7
8
struct Player
{
	string name;
	string team;
	int goal;
	int assist;
	int points;
}
Last edited on
1
2
3

a = (const struct x){ 0 };
Hi there I need a similar function can you please clarify swejnc?
1
2
3
4
5
6
7
8
while (name == list[i].name)
		{
			for (int i = 0; i < size; i++)
			{  
				list[i] = list[i+1];
				list[size-1] = (const struct Player) { 0 };	
                        }
    	        }


This compiles but I get an error that says " terminate called after throwing an instance of 'std : : logic_error'.
Topic archived. No new replies allowed.