Code:
void carrega_tabela(const char * ficheiro, int deficiente, int dependentes){
int i, j, marcador = 0;
float aux;
float taxa_irs;
float tabela[37][6];
FILE *f;
char * procura;
char string[1000], seps[] = " \n";
char *p;
if (deficiente == 0){
switch(dependentes){
case 0: procura = "NCASADO\0"; break;
case 1: procura = "CASADOUM\0"; break;
case 2: procura = "CASADODOIS\0"; break;
default: printf("<Erro: Numero de titulares incorrecto>"); break;
}
}else{
switch(dependentes){
case 0: procura = "NCASADODEF\0"; break;
case 1: procura = "CASADOUMDEF\0"; break;
case 2: procura = "CASADODOISDEF\0"; break;
default: printf("<Erro: Numero de titulares incorrecto>"); break;
}
}
printf("Procurar: %s\n", procura);
f=fopen(ficheiro,"r");
if(!f)
return 1;
i=0;
while(fgets( string, sizeof(string)-1, f) != NULL)
{
/* Break into tokens. */
p = string;
p = strtok( string, seps ); /* Find first token*/
j=0;
while( p != NULL )
{
if (marcador){
aux = atof(p);
printf("String: %s ", p);
printf("-> aux: = %.1lf - j=%d - i=%d\n",aux,j,i);
tabela[i][j] = aux;
j++;
}
if (strcmp(procura,p)==0){
marcador = 1;
}
p = strtok( NULL, seps ); /* Find next token*/
}
i++;
}
/*for (i=0; i < 6; i++){
for (j=0; j < 37; j++ ){
printf(" %.2lf",tabela[i][j]);
}
printf("\n");
}*/
}
The source file is:
Code:
NCASADO
575.00 0.0 0.0 0.0 0.0 0.0 0.0
580.00 1.0 0.0 0.0 0.0 0.0 0.0
587.00 2.0 0.0 0.0 0.0 0.0 0.0
633.00 3.0 1.0 0.0 0.0 0.0 0.0
675.00 4.0 2.0 1.0 0.0 0.0 0.0
726.00 5.0 3.0 2.0 1.0 0.0 0.0
801.00 6.0 5.0 3.0 2.0 1.0 0.0
907.00 7.0 6.0 4.0 3.0 2.0 1.0
988.00 8.0 7.0 6.0 4.0 3.0 2.0
1048.00 9.0 8.0 7.0 6.0 4.0 3.0
1124.00 10.0 9.0 8.0 7.0 6.0 5.0
1205.00 11.0 10.0 9.0 8.0 7.0 6.0
1300.00 12.0 11.0 10.0 9.0 8.0 7.0
1401.00 13.0 12.0 11.0 10.0 10.0 9.0
1537.00 14.0 13.0 12.0 12.0 11.0 10.0
1683.00 15.5 14.5 14.5 13.5 12.5 11.5
1840.00 16.5 15.5 15.5 14.5 13.5 13.5
1945.00 17.5 16.5 16.5 15.5 15.5 14.5
2056.00 18.5 17.5 17.5 16.5 16.5 15.5
2182.00 19.5 18.5 18.5 17.5 17.5 16.5
2328.00 20.5 19.5 19.5 18.5 18.5 17.5
2495.00 21.5 21.5 20.5 20.5 19.5 19.5
2722.00 22.5 22.5 21.5 21.5 20.5 20.5
3054.00 23.5 23.5 22.5 22.5 21.5 21.5
3478.00 24.5 24.5 23.5 23.5 23.5 22.5
4052.00 25.5 25.5 24.5 24.5 24.5 24.5
4576.00 27.0 26.5 25.5 25.5 25.5 25.5
5111.00 28.0 27.5 27.5 26.5 26.5 26.5
5786.00 29.0 28.5 28.5 27.5 27.5 27.5
6653.00 30.5 29.5 29.5 28.5 28.5 28.5
7852.00 31.5 30.5 30.5 30.5 29.5 29.5
9455.00 33.0 32.0 32.0 32.0 32.0 31.0
11159.00 34.0 33.0 33.0 33.0 33.0 32.0
18648.00 35.0 34.0 34.0 34.0 34.0 33.0
20000.00 36.0 35.0 35.0 35.0 35.0 34.0
22500.00 36.5 36.0 36.0 36.0 36.0 35.0
25000.00 37.0 37.0 37.0 37.0 37.0 36.0
25000.00 38.0 38.0 38.0 38.0 38.0 37.0
Can it be because of the dot instead of the comma?