Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: getc vs readline

by dave_the_m (Monsignor)
on Nov 30, 2019 at 19:57 UTC ( #11109490=note: print w/replies, xml ) Need Help??

in reply to getc vs readline

getc() uses the same input buffer as readline. getc() won't normally return after a single character like 'X' is entered; it waits until a whole line has been entered (including \n), then returns the first character of it. readline() sees the remainder of the line still in the buffer and returns immediately. For example, if the user types "abc\n", then at the point the user presses carriage-return, getc() returns "a" and readline() immediately follows on returning "bc\n".

If you truly want to get the next character even if the user hasn't pressed return yet, then look into something like Term::ReadKey.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11109490]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2020-02-29 04:06 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (128 votes). Check out past polls.