Hi!
I'm writing a program but i'm having some trouble in a function.
My problem is that when the function goes into the bolded cycle below a second time it doesn't enter the cycle and doesn't change the variable premio.
Here the whole function:
ThanksCode:void calcular_premios(int cod_seg) { system("cls"); ifstream fa; ifstream fb; sContrato c; char linha[100], *p; int cod_cob; float percentagem, premio=0; long pos; pos = procura_segurado(cod_seg); fa.open("contratos.bin",ios::in|ios::binary); if(!fa) return; fb.open("cobertura_premio.txt"); if(!fb) return; fa.seekg(pos); while(fa.read((char *)&c, sizeof c)) { if(c.cod_segurado == cod_seg) { fb.seekg(0, ios::beg); while(fb.getline(linha,100)) { p = strtok(linha,":"); cod_cob = atoi(p); p = strtok(NULL,"\n"); percentagem = (float)atof(p); if (c.cod_cobertura == cod_cob) premio+=(c.capital_apolice*percentagem); } } } fa.close(); fb.close(); }



LinkBack URL
About LinkBacks



