| |

VerySource

 Forgot password?
 Register
Search
Author: sanlban

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

[Copy link]

0

Threads

61

Posts

41

Credits

Newbie

Rank: 1

Credits
41

 China

Post time: 2020-4-18 16:30:01
| Show all posts
Press ctrl + z and press enter
Reply

Use magic Report

1

Threads

7

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

 Author| Post time: 2020-4-21 08:45:01
| Show all posts
Thank you for your kind help. . I know where the problem is. .

I have been typing this way before:
"
di yi hang (Enter)
di er hang (Enter)
...
di n hang (ctrl + z) (Enter)

"
In this way, the function of terminating the input cannot be achieved.


After entering the last line of text, remember to add a carriage return.
"
di yi hang (Enter)
di er hang (Enter)
...
di n hang (Enter)
(ctrl + z) (Enter)

"
/ *********************************** /

I also want to ask: What information is passed to the program by pressing ctrl + Z? Why doesn't it work without the last carriage return?
By the way,orangedjbrother, ctrl + D seems to be impossible.

thanks again!
Reply

Use magic Report

1

Threads

7

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

 Author| Post time: 2020-4-23 09:45:01
| Show all posts
Just switched to linux and tried it.
It turns out that linux uses ctrl + D to terminate the input ..
Reply

Use magic Report

2

Threads

50

Posts

31

Credits

Newbie

Rank: 1

Credits
31

 China

Post time: 2020-4-25 13:45:01
| Show all posts
ctrl + z
Then press enter
The purpose of the carriage return is to clear the input buffer buffer area, then the type will take effect immediately
Reply

Use magic Report

1

Threads

7

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

 Author| Post time: 2020-5-29 16:45:01
| Show all posts
ctrl + z
Then press enter
The purpose of the carriage return is to clear the input buffer buffer area, then the type will take effect immediately
-------------------------------------------------- ---------
Thank you for your answer. I still don't understand.
My questions are:
1. What information does ctrl + z (or ctrl + D) pass to the program?
2. Before ctrl + z, which is the end of the last line of input, why can't it end without adding a carriage return?
3. Under linux, using ctrl + D to end the input does not need to finish typing ctrl + z as under DOS and add another carriage return. Examples:
"
di yi hang (Enter)
di er hang (Enter)
...
di n hang (Enter)
(ctrl + D) (!! Note: There is no carriage return after ctrl + D)

"
Why is this? What message does the carriage return following ctrl + z under DOS convey?

Thank you for your advice ...
Reply

Use magic Report

0

Threads

1

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 China

Post time: 2020-8-18 14:00:01
| Show all posts
The EOF values ​​of machines in different environments are different.. You can print the EOF value first to take a look
#include <stdio.h>

int main(int argc, char *argv[])
{
  printf("%d",EOF);
  system("pause");
  return 0;
}
Reply

Use magic Report

0

Threads

1

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 China

Post time: 2020-8-18 19:30:01
| Show all posts
Upstairs, I'm afraid this won't work, how can I print out -1?
Reply

Use magic Report

1

Threads

8

Posts

8

Credits

Newbie

Rank: 1

Credits
8

 Netherlands

Post time: 2020-8-18 20:15:01
| Show all posts
ctrl+c
Reply

Use magic Report

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

Points Rules

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

Quick Reply To Top Return to the list