O
O
OblivionGM2021-09-17 05:29:25
Command line
OblivionGM, 2021-09-17 05:29:25

How to limit the number of input characters in ReadLine()?

There is a variable N, in which an integer number not exceeding 10000 is entered.
How can you limit the number of characters entered by the user to 5 without using if and loops?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vasily Bannikov, 2021-09-17
@vabka

It is possible through cycles and ReadKey.
But it's better to just let anything drive, and then validate and parse

E
eRKa, 2021-09-17
@kttotto

Under the circumstances, I suspect not. ReadLine simply reads the entire line from the buffer, it has no additional parameters for limiting.
And so the statement of the problem itself implies a cycle and a length check on each cycle.

G
Griboks, 2021-09-17
@Griboks

No, it's impossible!
ps
You need to use another input function or process the received data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question