1.4 Ctrl+D and Ctrl+Z issues (1.4)

APalley

Well-Known Member
I wonder why this would happen? In while loop, a crtl-D in a new line will not be counted as a word, but in do-while loop, it will be counted as a word.
A do-while loop will always loop at least once; this changes the dynamic of how the entire loop executes
 

Peter Wu

Active Member
C++ Student
@APalley Is it true that as a user, I need to press Ctrl+D and then press Enter to end my input process, instead of simply pressing Ctrl+D?
 

Junping Chen

Member
C++ Student
Hi @APalley
When I write
while((character=getchar())!=26)
Ctrl+z works in the output window
but when i use EOF to replace 26,^Z doesnt works if i only wrote one line in the output window,how can i use EOF successfully?
 

Junping Chen

Member
C++ Student
Hi @APalley
When I write
while((character=getchar())!=26)
Ctrl+z works in the output window
but when i use EOF to replace 26,^Z doesnt works if i only wrote one line in the output window,how can i use EOF successfully?
I mean I have tried both, but only 26 works, and somebug with EOF,When i use EOF, the output doesnt work in the first first typing line but only works in others
 

APalley

Well-Known Member
I mean I have tried both, but only 26 works, and somebug with EOF,When i use EOF, the output doesnt work in the first first typing line but only works in others
If you are using both, you need to be sure that you still only call getchar() one time per loop
 

Anqi Shi

Member
C++ Student
Hi all,when we input "\n", how can we determine it is a whole? My program seems always to view them separately. I use if(c == 10) to determine, but it does not work.
 

Anqi Shi

Member
C++ Student
Hi everyone, I am now using xcode on mac. However, I need to press ^D twice to end the input. Is it the normal situation?:X3:
 

WAN Xiaoyu

New Member
C++ Student
Use a variable to always store the previous character...

ctrlD on its own line should count as a line (but not a word)
I have read a lot of threads about how to count lines, some suppose that an empty line shoud not be counted as a newline, but this suggest that ctrlD on its own line should count as a line,so if I enter:
123
^D
this is 1 line or 2 lines?
@APalley
 
Top