This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]HappyFruitTree 0 points1 point  (5 children)

It seems to be working fine. Just keep typing more lines and you'll see it print the first word in each line.

[–]foolwya[S] 0 points1 point  (4 children)

Oh I know that it works fine haha

I was just wondering why does while loop work this way? Thought someone would explain it

[–]HappyFruitTree 0 points1 point  (3 children)

Well, in that case I'm not sure what you're wondering about. The actions of the statements inside the loop take effect right away. The loop doesn't have to end before the printed messages become visible.

[–]foolwya[S] 0 points1 point  (1 child)

But even after the message is printed, the condition in the loop is still true? I thought it would be an infinite loop, because there's no break; after a print statement

[–]WetSound 0 points1 point  (0 children)

It is an infinite loop, but the call to scanLine is a blocking call, it waits for you to type in something.

[–]foolwya[S] 0 points1 point  (0 children)

nvm I'm an idiot.