1
In a validation function that passes the tests all will return 1, and if you enter one of the conditions will give return
to 0.
I want to cycle until the line breaks, so I’m using the interval:
for(int i=0;dados[4][i]!='\n';i++){
if(!isdigit(dados[4][i])){
return 0;
}
}
The file has already been split and stored in a matrix dados[4][20]
, being the lines of the genre
4 ; Visitante ; 3 ; 0 ; 3 \n
4 ; Visitante ; 3 ; 0 ; 3 \n
4 ; Visitante ; 3 ; 0 ; 3 \0
However, at the last line of the file, there is no more line break but a \0
, soon will not allow us to validate the last line
I suggest you add more content so we can help. This is a run file? Parsed lines already? is a parse of line fields? is n a line break? is it an empty line? I suggest you edit and rephrase the question.
– Michel Simões
I’ll rephrase then
– Bruno Bacelar
But how was the array created? Because the description gives the idea that it has 4 rows and 20 columns, but then the
for
It seems to only advance in the columns instead of through the rows. If the array was created with a certain size (20) why not iterate up to 20 or up to the amount that was read from the file ? That would be easier and more intuitive. Regardless of all this "given what I’ve been able to interpret from the question" it seems to me that I just change the condition todados[4][i]!='\n' && dados[4][i]!='\0'
would work.– Isac
@Brunobacelar Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already done so. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site.
– Maniero