I need to read from a file the number of tests to be done and which tests to run. The input file is as follows:
4 //Numero de testes a serem feitos
1 LINSIMP 3 //Primeiro(1) teste que verifica se a linha 3 é simples
2 LINPOL 3 1 //Segundo(2) teste que verifica se a linha 3 intercepta poligono 1
3 POLSIMP 1 //Terceiro(3) teste que verifica se o poligono 1 é simples
4 PTOPOL 1 1 //Quarto(4) teste que verifica se o ponto 1 está no poligono 1
The number of tests (which are four) has already been implemented through the function:
int LeNumeroDeTestes(FILE *entrada)
{
int numTestes;
fscanf(entrada, "%d", &numTestes);
return numTestes;
}
However, I'm having a hard time finding a way to read the rest of the input file. I've implemented the following:
int i, LinhaTeste;
char Teste[10];
for(i = 0; i < numTestes; i++)
{
fscanf(entrada, "%d", &i);
fscanf(entrada, "%s", Teste);
if(i == 0)
{
fscanf(entrada, "%d", &LinhaTeste);
printf("%d %s %d", i, Teste, LinhaTeste);
}
}
But it does not look like a very good solution. Also, although no compilation errors occur, nothing is printed on the screen. (I did not finish the cases of i = 1, 2 and 3).
I would like to know a better way to read this file.