Help it won't compile!!!!!
Beautiful programminig style and use of variables ;) but it won't compile
101 error: syntax error before 'printf'
I don't use switch statements much or initialise characters arrays much either so maybe the problem is there?
Probably something simple and stupid but I can't see it.
Code:
#include <stdio.h>
#include <stdlib.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;
//M 6QUN N
xx=(int)var2[2];
yy=(int)var2[3];
gg=(int)var2[0];
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][xx][yy]++;
tots[g1]++;
}
printf("\n Done");//<------------------------------------arrrrrrrrgggggggghh!! (line 101)
for(g1=0;g1<3;g1++){
if (c1==c2) printf("%c %c%c %d\n", typ[g1], face[c1],face[c2], crds[c1][c2]);
}
fclose(ptr2);
fclose(ptr3);
}