Can't figure out what to do with this code

I have to write this card game, SCAT or 51, using pointers and structs. I have to read in the deck from a file and read in the players from a separate file. I cant figure out how to get it work properly. Any help would be great.

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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstring>
using namespace std;

struct card{
	char rank[5];
	char suit[7];
	int cvalue;
	char location[4];
	};
struct player{
	int total;
	char name[100];
	};

void strcopy(char* &to, char* from);
void card_copy(card* &dest, card *source);
void choice_one();
void choice_two();
void choice_three();
void get_menu();
int main()
{
	int choice;
	do{
		get_menu();//Displays the menu
		cout << "Enter you choice: ";
		cin >> choice;
		cout << endl << endl;
	}while (choice == 1 && choice == 2 && choice == 3 && choice == 4);
	switch (choice)
		{
			case 1: 
				{
					choice_one();
					break;
				}
			case 2: 
				{
					choice_two();
					break;
				}
			case 3: 
				{
					choice_three();
					break;		
				}
			case 4: 
				{
					cout << "Goodbye!\n\n";
					break;
				}
				
		}

	return 0;
}

void get_menu(){
	cout << endl << endl;
	cout << "Choose an option\n"
	     << "-------------------\n"
	     << "1. Print unshuffled deck to screen\n"
	     << "2. Print shuffled deck to the screen\n"
	     << "3. Print players\n"
	     << "4. Quit\n\n";
}

void choice_one()
{
	fstream fin;
	fin.open("unshuffled");
	card unshuff[52];
	card* uptr1;
	uptr1 = unshuff;
	card* uptr2;
	uptr2 = unshuff;
	for (int i = 0; i < 51; i++)
		{
			fin >> (*uptr1).rank;
			fin >> (*uptr2).suit;
			card_copy(uptr1, uptr2);
			cout << uptr1 << endl;
			*uptr1++;
		}				
	fin.close();
	cout << endl << endl;
}

void choice_two()
{
	char filename[100];
	cout << "Enter the filename you would like to read from: ";
	cin >> filename;
	fstream fin;
	fin.open(filename);
	card unshuff[52];
	card* cptr1;
	card* cptr2;
	cptr1 = unshuff;
	cptr2 = unshuff;
	for (int i = 0; i < 51; i++)
		{
			fin >> (*cptr1).rank;
			fin >> (*cptr2).suit;
			cout << cptr1;
			cptr1++;
			cptr2++;
		}						
	card *p1, *p2;
	card *temp;
	card *t = temp;
	int num1 = rand() % 52;
	int num2 = rand() % 52;
	srand (time(NULL));
	for (int i = 0; i < 200; i++)
		{
			p1 = unshuff;
			p2 = unshuff;
			for (int i = 0; i < num1; i++)
				{
					p1++;
				}
			for (int i = 0; i < num1; i++)
				{
					p2++;
				}

			card_copy(t, p1);
			card_copy(p1, p2);
			card_copy(p2, t);
		}
	fin.close();
	cout << endl << endl;
}

void choice_three()
{
	char filename[100];
	cout << "Enter the filename you would like to read from: ";
	cin >> filename;
	fstream fin;
	fin.open(filename);
	player playa1[5];
	player playa2[9];
	player *nptr1;
	nptr1 = playa1;
	player *nptr2;
	nptr2 = playa2;
	cout << "The players are: \n\n";
	for (int i = 0; i < 4; i++)
		{
			fin >> (*nptr1).name;
			fin >> (*nptr2).name;
			cout << (*nptr1).name << " " << (*nptr2).name << endl;
		}			
	fin.close();
	cout << endl << endl;
}

void strcopy(char* &to, char* from)
	{
		char *reset = to;
		while (*from != '\0')
			{
				*to = *from;
				to++;
				from++;
			}
		*to = '\0';
		to = reset;
	}

void card_copy(card* &dest, card *source)
	{
		strcpy ((*dest).suit, (*source).suit);
		strcpy ((*dest).rank, (*source).rank);
		(*dest).cvalue = (*source).cvalue;
	}
closed account (48T7M4Gy)
What exactly is the first thing that's not working properly?
Topic archived. No new replies allowed.