@claudiu: thanks for the help. but it is ok with the space though
@laserlight and Bayint sorry I forgot about it:
@Salem: enum is a same way to do that
I post 2 place to get more help. here and codecall. I dont copy and paste. I've try to do this since 2 days a go... sorry for multiple posts.
this is the code
I got error at line 52 "fscanf(infile, "%s", KBLottoPlayer[i].lastName);"
with syntax error: invalid type "int[int]' for array subscript
Code:
//
// PID: k1368475
// Assignment: 1
// Knightlottery Ball
// Standard library declaration
#include <stdio.h>
#include <stdlib.h>
// Define numbers player and prize for matched numbers
#define Played_number 6
// Stores information for the KnightsBallLottoPlayer
typedef struct KnightsBallLottoPlayer {
char firstName[20];
char lastName[20];
int numbers[6];
int count;
} KBLottoPlayer;
enum match
{
three = 10,
four = 1000,
five= 10000,
six = 1000000
};
int main (void)
{
FILE * infile;
FILE * outfile;
infile = fopen ("input.txt", "r");
outfile = fopen ("output.txt", "w");
int i, j;
int KBLottoPlayer;
int winners [6];
int k;
int* p;
int tickets = 0;
//scan the tickets
fscanf(infile, "%d", &tickets);
p = (int *)malloc(KBLottoPlayer*sizeof(int));
for (i = 0; i < tickets; i++)
{
fscanf(infile, "%s", KBLottoPlayer[i].lastName);
fscanf(infile, "%s", KBLottoPlayer[i].firstName);
for (j = 1; j <= Played_number; j++)
{ fscanf(infile, "%d", KBLottoPlayer[i].Played_number[j]);
}
}
printf("Please enter the winning lottery numbers:\n");
scanf("%d %d %d %d %d %d", &winners[0], &winners[1], &winners[2], &winners[3], &winners[4], &winners[5]);
for (i = 0; i < Played_number; i++)
{
printf("%d ", winners[i]);
}
for (i = 0; i < j; i++)
{
for (j = 0; j < Played_number; j++)
{
for (k = 0; k < Played_number; h++)
{
if (KBLottoPlayer[i].nums_played[j] == winners[k])
{
KBLottoPlayer[i].count++;
}
}
}
}
for (i = 0; i , tickets; i++0
{
if (KBLottoPlayer[i].count >= 3)
printf("%s %s matched %d numbers and won $%d.\n", KBLottoPlayer[i].firstName, KBLottoPlayer[i].lastName, KBLottoPlayer[i].count);
fclose(infile);
fclose(outfile);
system("PAUSE");
return 0;
}