Created
December 21, 2015 22:50
-
-
Save luistelmocosta/bc494c4f9c90718f38d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Campeonato::readFileBilhetes(string filename) { | |
ifstream ficheiro_leitura(filename.c_str()); | |
vector<Prova*> vecprovas = calendario->getProvas(); | |
vector <int> indices; | |
if(!ficheiro_leitura) | |
throw ErroNoFicheiro(filename); | |
else{ | |
string dono, data, provas; | |
unsigned int duracao; | |
while (!ficheiro_leitura.eof()){ | |
getline(ficheiro_leitura, dono); | |
getline(ficheiro_leitura, data); | |
getline(ficheiro_leitura, provas); | |
//duracao=atoi(durtmp.c_str()); | |
stringstream dataSs; | |
date d; | |
dataSs << data; | |
int dia, mes, ano; | |
char tmp; | |
dataSs >> dia >> tmp >> mes >> tmp >> ano; | |
if(dia < 1 || dia > 31|| mes < 1 || mes > 12 || ano < 1 || (dia > 28 && mes == 2) || (dia > 30 && mes == 4) || (dia > 30 && mes == 6) || (dia > 30 && mes == 9) || (dia > 30 && mes == 11)){ | |
cout << "Data invalida!"; | |
} | |
else{ | |
d.dia = dia; | |
d.mes = mes; | |
d.ano = ano; | |
} | |
stringstream provasS; | |
int i = 0; | |
while (provas[i] != '\n' && provas[i] != '\0'){ | |
if(provas[i] == ','){ | |
int indice = provasS; | |
indices.push_back(indice); | |
} | |
else | |
provasS << provas[i]; | |
++i; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment