Do boolean statements get executed or just evaluated? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Do boolean statements get executed or just evaluated?

Sorry if the title is not very clear. Thing is; suppose I have a while loop that reads a string from a file and stores it into an array with fscanf. Clearly, I need this loop to be executed until fscanf returns EOF. The thing is, if my code says something like while (fscanf(file, "%s", array) != EOF) will the statement be actually executed? That is, will fscanf read the file and copy a string into the array, or will it just verify if it returns EOF and proceed to execute the branch within {}? Thanks in advance

2nd Jul 2020, 6:30 PM
Antônio Gabriel Zeni Landim
Antônio Gabriel Zeni Landim - avatar
1 Answer
+ 2
First it will read the string into array, then fscanf returns the number of items or variables filled or read..
2nd Jul 2020, 6:52 PM
Jayakrishna 🇮🇳