Okey cokey pig in a pokey!!

Here is a version which works, what it does is read a file of cards I have been dealt at poker with an input such as:- M K8

You can ignore the first letter its a 'game type' but the K=KING and 6 = 6

Then it counts up the number of 'pairs' I have been dealt, there are not many in the test data at the moment.

Incidently

M=a game which I used points to enter

F=a free game (freeroll)

P=a game I paid money to play - notice I didn't get many pocket pairs!!!

Code:

#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>
#include <errno.h>
FILE *ptr1, *ptr2, *ptr3;
int filelist;
int crds[3][13][13];
int tots[3];
char face[13]={'2','3','4','5','6','7','8','9','T','J','Q','K','A'};
char typ[3]={'F','M','P'};
int gg, xx, yy, c1, c2, g1;
char var2[300]="";
//M 6QUN N
main(argc,argv)
int argc;
char *argv[];
{
if ( (ptr2=fopen("hands.doc","r")) == NULL) {
puts("file2 does not exist");
exit(2); /* an early file does not exist */
}
if ( (ptr3=fopen("handoutput.txt","w")) == NULL) {
puts("\nCant open output file");
exit(2); /* an early file does not exist */
}
do{ /* for each line in dirfile file */
filelist=fscanf(ptr2,"%[^\n]\n",var2);
if (filelist==-1) break;
// printf("\n var2<%s>",var2);
//M 6QUN N
xx=(char)var2[2];
yy=(char)var2[3];
gg=(char)var2[0];
printf("\n %c %c%c",gg, xx,yy);
switch(xx){
case 'A': c1=12; break;
case 'K': c1=11; break;
case 'Q': c1=10; break;
case 'J': c1=9; break;
case 'T': c1=8; break;
case '9': c1=7; break;
case '8': c1=6; break;
case '7': c1=5; break;
case '6': c1=4; break;
case '5': c1=3; break;
case '4': c1=2; break;
case '3': c1=1; break;
case '2': c1=0; break;
default: printf("\n Invalid card 1");
}
switch(yy){
case 'A': c2=12; break;
case 'K': c2=11; break;
case 'Q': c2=10; break;
case 'J': c2=9; break;
case 'T': c2=8; break;
case '9': c2=7; break;
case '8': c2=6; break;
case '7': c2=5; break;
case '6': c2=4; break;
case '5': c2=3; break;
case '4': c2=2; break;
case '3': c2=1; break;
case '2': c2=0; break;
default: printf("\n Invalid card 2");
}
switch(gg){
case 'P': g1=2; break;
case '1': g1=0; break;
case '2': g1=0; break;
case '5': g1=0; break;
case 'C': g1=1; break;
case 'M': g1=1; break;
default: printf("\n Invalid game type");
}
(crds[g1][c1][c2])++;
(tots[g1])++;
} while(1);
printf("\n Done\n\n");
// printf("\n %d"
for(g1=0;g1<3;g1++){
for(c1=0;c1<13;c1++){
for(c2=0;c2<13;c2++){
if (c1==c2) printf("%c %c%c %d\n", typ[g1], face[c1],face[c2], crds[g1][c1][c2]);
}
}
printf("\n");
}
fclose(ptr2);
fclose(ptr3);
}

Test output.

Code:

M 5Q
M J9
M T6
M 9T
1 5Q
1 62
M 96
M 87
M 2J
M Q2
M 5Q
M Q3
M A5
M K8
M TA
M 62
M 5K
M 87
M T3
M JA
M A4
M 9J
M J4
M 2Q
M 83
M T3
M 46
M 85
M 74
M 65
M 83
M AJ
M A9
M TA
M 38
1 JJ
1 92
1 23
1 A9
M KA
M J6
M 84
1 5A
1 TT
M 45
M KT
M TA
M 32
1 Q2
1 47
M A9
M 48
M 72
1 TK
1 24
1 QK
1 A2
M Q2
M 98
M 44
M 3J
1 84
1 45
1 42
M 27
M J9
M 35
M 79
M Q4
1 4Q
1 AA
1 4J
1 9K
1 T8
M K2
M 98
M 95
M 7K
M 78
1 A6
1 JT
M 38
M 63
1 86
1 82
1 83
M K5
1 JQ
M JQ
M T3
M T5
M A3
1 23
M QA
M Q6
1 4J
M K5
1 8Q
1 7J
M K7
M 76
1 3K
M K4
1 65
M 69
M 85
M 7Q
M TQ
M 4Q
M 5J
M TA
1 QJ
M T5
M J3
1 7T
1 7T
M 8K
1 46
1 K2
M TA
M 23
M 7J
M 35
M 49
M 78
1 99
M 76
M K5
1 4T
1 Q6
M 6K
1 K7
M KJ
M 6K
M K4
M 6T
M J7
M 3Q
M K8
1 KA
M A6
1 37
M 49
1 9K
M 85
M TQ
M 52
M 82
M 8Q
M 93
M 67
M A9
M 48
1 27
M 7K
M 53
1 4A
1 23
M 34
1 Q7
1 66
1 46
M 73
M 89
M 79
M 2A
M 6K
M 34
M K2
1 87
1 J8
M A3
1 TQ
M JQ
M A9
1 98
1 6J
M 7J
M K7
1 46
1 5Q
1 69
1 JA
M 4T
M 46
M QA
1 92
1 AT
M 53
M 3T
M 7A
M 97
M AK
M T9
M 5A
M JJ
M 64
M JK
M 3K
M J7
M 28
M J6
M 46
M A4
1 6J
1 94
1 59
M 37
M Q2
1 28
M K3
M 62
M 6A
1 JT
1 33
M 3J
M 9T
M 28
M J8
M A3
M 45
M J9
M Q9
M 97
M 48
M T5
M Q6
M 3K
M 89
M 96
1 Q3
1 4K
1 54
M 2Q
M 53
M 93
M 69
1 K8
1 A8
1 A5
M Q6
M 39
M 37
M T2
M J3
1 54
1 65
1 T3
M 4A
M 46
M Q2
M KQ
M A6
M A5
1 K4
1 4A
1 45
1 A9
1 4J
M 2T
M 9A
M 2A
M 32
M 53
M 9J
M J9
M 8K
M 69
1 2Q
1 5T
1 68
1 QQ
M 7K
M 5A
M Q9
M 37
M K9
M 93
M 7T
M T3
M KQ
M 6J
M 46
M 42
M A7
M A2
M QK
M 3J
M 65
M A4
M 4J
M 29
M 8A
M KA
M 2J
M 95
M 74
M J6
M 9A
M 43
M K9
M 52
M 98
M QA
M T9
M JT
M 49
M 4T
M T2
M 59
M 63
M J8
M KJ
M 38
M A4
M 73
M A5
M QJ
M 8A
M T3
M A5
M 69
M 7J
M 8K
M 5A
M KA
M 9A
M 2K
M 5K
M 8K
M 89
M 9Q
M 53
M 73
M 47
M 6T
M K7
M 54
M 99
P 87
P Q7
P KT
P 76
P 62
P 37
P T4
P 8J
P 7Q
P 28
P JK
P 95
P 8T
P AQ
P 5Q
P 24
P 4J
P KT
P JK
P A8
P 62
P 99
P 3A
P 56
P 98
P JQ
P JQ
P 93
P J9
P 46
P A5
P J8
P 7T
P 29
P Q9
P 4J
P TJ
P 3Q
P 9A
P 32
P 3Q
P 67
P Q5
P 44
P Q2
P 2K
P K3
P 5T
P TJ
P 72
P 5A
P J2
P Q6
P 8T
P 9A
P JT
P 5J
P Q9
P 2K
P J6
P A7
P 3K
P KQ
P 69
P 79
P 98
P A6
P Q4
P 95
P JT
Done
F 22 0
F 33 1
F 44 0
F 55 0
F 66 1
F 77 0
F 88 0
F 99 1
F TT 1
F JJ 1
F QQ 1
F KK 0
F AA 1
M 22 0
M 33 0
M 44 1
M 55 0
M 66 0
M 77 0
M 88 0
M 99 1
M TT 0
M JJ 1
M QQ 0
M KK 0
M AA 0
P 22 0
P 33 0
P 44 1
P 55 0
P 66 0
P 77 0
P 88 0
P 99 1
P TT 0
P JJ 0
P QQ 0
P KK 0
P AA 0

Gonna run a huge test now and count all card hands, not just 'pocket pairs'. in the paid game!!

and see it the distribution is even

Actually I just realised I didn't play many paid games!! (so thats OK), I wil have to average it.