I knew of no better place to ask, and I am probably going to go full newb here with this one.
Keep in mind…
- I am using Windows.
- I am using GCC.
Alright, to the fun part. If I use this, the while loop will never exit:
while((c = getchar()) c != EOF)
From what I can tell, this is due to getchar() absorbing the return key and is a consequence of using Windows, however if I do this instead:
while((c = getchar()) != '
' && c != EOF)
I will be good to go and things will work.
I don’t like this behaviour, and here comes the kicker, maybe I WANT to count the newline. I don’t want to use ANY other input method. Assume I want to use getchar(). Is there a way for me to count the
and have my while loop not stick? Maybe I am just being typical and looking over something simple?
Thanks!
Edit: NO, CtrlZ & F6 are not solutions!