c++ program

this program can't working properly please mantion the mistake what we have done
in this program. 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
 #include <iostream.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

class Player {
    private:
        char name[20];
        int score; 

    public:
        Player(){
            strcpy(name, "\0");
            score = 0;
            //cout<<"Constructor Called";
        }
        ~Player(){
            //cout<<"Destructor Called";
        }
        void setName(){            
            cin>>this->name; 
        }
        char* getName(){
            return this->name;
        }
        void setScore(int score){
            this->score = score;
        }                   
        int getScore(){
            return this->score;
        }     
};    

void displayInformation () {
cout<<"This is a mini Game, allowing three players to contest.";
cout<<"Each Player will have to open three boxes from given one hundred boxes in 3 turns.";
cout<<"There is a secret number in each box. In each turn number, the secret number inside the selected box will add-up to the total score of player.  At the end, it will display the summary of score of each player.\n\n";
}

void fillBoard(int array[10][10]){
    srand(time(0));
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            array[i][j] = rand()%100+1;
        }    
    }
}   
void displayBoard(int array[10][10]){
    int *ptr = *array;
    
    system("cls");
    
    displayInformation();
    
    for(int i = 1; i <= 100; i++){
        if(*ptr != 0){
            //cout<<i<<"("<<*ptr<<")\t";
            cout<<i<<"\t";
        }
        else {
            cout<<"X\t";
        }        
        ptr++;
            
        if(i%10 == 0) 
            cout<<endl;
    }
    cout<<endl;
    ptr = NULL;
}    
int openBox(int grid[10][10]){
    int *ptr = *grid, choice = 0, secretNumber = 0;
    cout<<"Enter the number of box to open it: ";
    cin>>choice;
	    
    ptr = ptr+choice-1;  
    secretNumber = *ptr;
    *ptr = 0;
    return secretNumber;
}    

void sortPlayers(Player players[], int size){
		
	// put your code here to sort the players in descending order on the bases of score
	// Example Input
	// Uzma 233
	// Ali 280
	// bc123456899  250

	// Desired Output
	// Ali 280
	// bc123456899  250
	// Uzma 233
		
}

main(){
    int size = 3, board[10][10] = {0};
    Player players[size];
    
    
    displayInformation();
    
    for(int x = 0; x < size; x++) {
    	fillBoard(board);
    	cout<<"Enter name of player "<<x+1<<" of "<<size<<": ";
		players[x].setName();    	
    	
    	for(int i = 1; i <= 3; i++){
    		displayBoard(board);
			cout<<"Turn "<<i<<" of 3"<<endl;
    		
    		if(i < 3) {
    			players[x].setScore(players[x].getScore()+openBox(board));
			}
			else{
				char choice = '\0';
            	int offer = 25+rand()%51;
            	cout<<"Special offer take: "<<offer<<endl<<endl;
            
            	cout<<"You can take special offer or open last box."<<endl;
            	cout<<"To take special offer press y or Y and any other character to open your last box: ";
            	cin>>choice;
            
            	if(choice == 'y' || choice == 'Y'){
                	players[x].setScore(players[x].getScore()+offer);
            	}    
            	else{
                	players[x].setScore(players[x].getScore()+openBox(board));
            	}	    
            }                
            cout<<endl<<endl;        	
		}	     	
    	cout<<"Your Score: "<<players[x].getScore()<<endl<<endl;
	}  
	
	sortPlayers(players, size); 
	
	cout<<"----------  Result Summary --------------   "<<endl;
	for(int k = 0; k < size; k++) {
		cout<<players[k].getName()<<"\t Score: "<<players[k].getScore()<<endl;
	}
	cout<<endl;
    system("pause");    
}    
Is your program:
1) Not compiles
    * Is other code compiles correctly, i. e. is your compiler configured properly
    * If so, give us error message and corresponding code part.
2) Not running
    * Are you sure that it is not a problem with automatically closing console?
    * How do you run it?
    * Is there any error messages?
3) Gives an error when run
    * Is it system error message or error reported in console?
    * Give us error message and input which leads to error.
4) Not giving correct results
    * Tell what you entered, what you expected, and what you got.
    * Are you sure that results you expected are correct?
Duplicate of http://www.cplusplus.com/forum/general/156361/

Please don't spam the forum with multiple threads for the same topic.
Topic archived. No new replies allowed.