| |

VerySource

 Forgot password?
 Register
Search
View: 1763|Reply: 17

What input does EOF refer to when accepting characters with getchar? Thank you!

[Copy link]

1

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-2-11 22:00:01
| Show all posts |Read mode
Beginner, please advise.

for example:
/ ***************************************** /
#include <stdio.h>

 / * count lines in input * /
int main (void)
{
int c, nl;
Ranch
nl = 0;
while ((c = getchar ())! = EOF)
if (c == '\n')
++ nl;
printf ("% d\n", nl);
getch ();
Ranch
return 0;
}
/ ***************************************** /

I cannot stop typing while running this program. In other words, it is impossible to reach the (c = getchar ()) == EOF step. What is going on?

Thank you for your excellent suggestion!
Reply

Use magic Report

0

Threads

63

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-4-7 20:30:01
| Show all posts
ctrl + z or ctrl + D or end of file
Reply

Use magic Report

1

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-4-8 13:15:01
| Show all posts
orangedj(swing pull, swing pull)
ctrl + z or ctrl + D or end of file
---------------------
Thank you for your answer. I use keyboard input, I can't use ctrl + z or ctrl + D to end input.
Ask how to do?
Reply

Use magic Report

0

Threads

63

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 United States

Post time: 2020-4-8 23:30:01
| Show all posts
Can't find ctrl and Z Jian? Then use the mouse to click on the soft keyboard
Reply

Use magic Report

0

Threads

63

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-4-9 09:15:01
| Show all posts
ft, it ’s a bit difficult to click 2 keys at once
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-4-13 23:30:01
| Show all posts
orangedj(swing pull, swing pull)
ctrl + z or ctrl + D or end of file
---------------------
Thank you for your answer. I use keyboard input, I can't use ctrl + z or ctrl + D to end input.
Ask how to do?
_____________________________________________________________
_____________________________________________________________
Faint! ! ! "I use keyboard input, I can't use ctrl + z or ctrl + D to end input" What is this? Is the keyboard broken? ? ? ? While typing, press and hold ctrl + z at the same time to end! (DOS)
Reply

Use magic Report

1

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-4-14 13:15:01
| Show all posts
Oh, sorry, I didn't make it clear.

I mean that I can't end typing with ctrl + z or ctrl + D.

When I press ctrl + z, ^ Z is displayed in the console, but it does not affect my continued input.
Reply

Use magic Report

0

Threads

24

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-4-14 19:00:02
| Show all posts
All right
Reply

Use magic Report

1

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-4-14 20:30:02
| Show all posts
orangedj(swing pull, swing pull)
ctrl + z or ctrl + D or end of file
---------------------
Thank you for your answer. I use keyboard input, I can't use ctrl + z or ctrl + D to end input.
Ask how to do?
_____________________________________________________________
_____________________________________________________________
Faint! ! ! "I use keyboard input, I can't use ctrl + z or ctrl + D to end input" What is this? Is the keyboard broken? ? ? ? While typing, press and hold ctrl + z at the same time to end! (DOS)
-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------------
Ha ha, I am also very dizzy, I don't know if I am wrong.
What I mean by "keyboard input" is to distinguish it from reading file input.
The latter sentence should be changed to "Cannot end input with ctrl + z or ctrl + D".
I am under the DOS console.
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-16 17:00:01
| Show all posts
I still don't believe it:
   ctrl + break
  nnd! !
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list