
August 7th, 2002, 08:51 AM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
Here is a simple way that you could do it:
Code:
#include <stdio.h>
#include <string.h>
typedef struct _card {
int id;
char suit;
int placement;
} card;
main () {
card deck[52];
int counter=0;
char working[10];
char *temp=&working[0];
char *test;
FILE *card_data_file;
bzero(working,10);
card_data_file = fopen("data.txt","r");
if (card_data_file == NULL) {
printf("Error reading card data file.");
return -1;
}
for(counter=0;counter < 52;counter++) {
fgets(temp, 10, card_data_file);
deck[counter].id=atoi(strtok(temp," "));
test=strtok(NULL," ");
deck[counter].suit=test[0];
deck[counter].placement=atoi(strtok(NULL," "));
}
fclose(card_data_file);
for(counter=0;counter < 52; counter++) {
printf(" Card %d%c is at position %d in the deck\n",
deck[counter].id,
deck[counter].suit,
deck[counter].placement);
}
printf("\nEnd\n");
return 1;
}
|