Hi
I just try to do like this, like arrays
Code:
void jg2(struct perg *p)
{
char lista[1000][256]; // mil perguntas com tamanho máximo de 255 caracteres
int count;
int n, i;
FILE *f;
if ((f = fopen("Atividades/gp1.dat", "wb")) == NULL)
{
printf("Erro ao abrir ficheiro\n");
}
else
{
fread(p, sizeof *p, 1, f);
count = 0;
while (fgets(lista[i], 256, f) == lista[i])
count++;
// fechar ficheiro
fclose(f);
//escolher pergunta
n= rand() % count;
}
printf("Bemvindo ao jogo curto do BUZZ, boa sorte \n");
}
Using the char lista to hold questions from text
Then i open my file (gp1.dat)
Read it
fgets to get the text to the array..
Variable i unused.