| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | bridval.c |
Hello All!
I used the following program to do the conversion. I had to change the
10's to T's though. BFN.
/*********************************************************************/
/* */
/* This Program Written by Paul Edwards. */
/* Released to the Public Domain */
/* */
/*********************************************************************/
/*********************************************************************/
/* */
/* bridval - calculate the value of a card in bridge order */
/* */
/*********************************************************************/
#include
#include
int main(int argc, char **argv)
{
FILE *fp, *fq;
char buf[2000];
int num;
int ch;
int rc;
if (argc < 3)
{
printf("useage: bridval \n");
return (EXIT_FAILURE);
}
fp = fopen(*(argv+1), "r");
if (fp == NULL)
{
printf("can't open %s\n", *(argv+1));
return (EXIT_FAILURE);
}
fq = fopen(*(argv+2), "w");
if (fq == NULL)
{
printf("can't open %s\n", *(argv+2));
return (EXIT_FAILURE);
}
while (fgets(buf, sizeof buf, fp) != NULL)
{
if (sscanf(buf, "%c%c", &num, &ch) != 2)
{
break;
}
switch (num)
{
case 'A': num = 1;
break;
case '2': num = 2;
break;
case '3': num = 3;
break;
case '4': num = 4;
break;
case '5': num = 5;
break;
case '6': num = 6;
break;
case '7': num = 7;
break;
case '8': num = 8;
break;
case '9': num = 9;
break;
case 'T': num = 10;
break;
case 'J': num = 11;
break;
case 'Q': num = 12;
break;
case 'K': num = 13;
break;
default: num = 2000;
break;
}
switch (ch)
{
case 'C':
num += 0;
break;
case 'D':
num += 13;
break;
case 'H':
num += 26;
break;
case 'S':
num += 39;
break;
default:
num += 2000;
break;
}
fprintf(fq, "%d\n", num);
}
return (EXIT_SUCCESS);
}
Paul
--- GoldED/2 2.42.G1114
* Origin: Ten Minute Limit (3:711/934) |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.