| |

VerySource

 Forgot password?
 Register
Search
Author: yifei110

scanf weird

[Copy link]

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-3-26 13:00:01
| Show all posts
Ok.
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-3-26 21:45:01
| Show all posts
>> Be sure to use the most standard method, then only while (getchar ()! = '\n');

This is not true. This method may be even worse, because changing the platform may cause unexplained waiting and lease congestion, huh, huh.
Because standard carriage returns / line feeds / spaces / tabs are delimiters for scanf, they should be ignored.

But I do n’t know what Microsoft is doing. This is not the case since the DOS era. Instead, it makes scanf read a newline, which makes people lose their temper.
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-3-27 11:00:01
| Show all posts
Oh, I was wrong. --b.
Even if it is scanf, you give getchar, sorry.
Reply

Use magic Report

0

Threads

55

Posts

44.00

Credits

Newbie

Rank: 1

Credits
44.00

 Invalid IP Address

Post time: 2020-3-29 00:00:01
| Show all posts
Er, I haven't considered the situation where the buffer is empty. It seems that there is no better solution than fflush.
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