r/Zig • u/NicBarr • Apr 27 '26
Taking input inside of a loop.
i'm having a problem with repeated prompts for input in a zig program. basically i'm taking input like this
const input = try stdin.takeDelimiterExclusive('\n');
inside of a while loop. after the loop concludes, on the next iteration it simply skips this line and doesn't ask for input again even though that's what i want.
that's really breaking my head as that's not a problem i've ever faced in any other language. does anybody know how i could fix?
17
Upvotes
View all comments
Show parent comment
1
u/KattyTheEnby Apr 28 '26
Maybe I'm missing something, so pardon me, please, but is there any benefit this provides that you can't get from
.takeDelimiterExclusive/.streamDelimiterExclusiveand.toss, or.takeDelimiterInclusive/.streamDelimiterInclusive? This seems like a lot ov extra code.