I have to code a function that validates a text file. I am struggling with the two possibilities.
The first line is always a country. I have created a vector of strings with some country’ names. Then, the second line has to be a city. After, a first and last name follow. However, if the text file contains more information, I have to validate whether the next line is a city or a first name. I thought about incrementing the loop:
Below is my pseudo-code.
while(« reading line by line »){
i++;
If line is empty
Return false
Else if line is not empty
Read line;
i=0;
if (i%2==1){
« If line is not city »
return false;
else
Read line;
i=0;
else
If line is empty
Return false
Else
if line is not empty
Read line
if (i%2==0){
If line is empty
Return false
If line is not empty
Read line}
Then, the program has to start again. However, when I try my program: if I erase the country, the program is still working and skipping the false condition. What should I do?
Thank you
Aucun commentaire:
Enregistrer un commentaire