Problem with scanf()/gets()

  • Thread starter subratasinha2006
  • Start date
C

CBFalconer

Walter said:
Do you mean input from a terminal? That may be limited by your
operating system.

However,

C89 4.9.2 Streams
[...]

Environmental Limits

An implementation shall support text files with lines
containing at least 254 characters, including the terminating
new-line character. The value of the macro BUFSIZ shall be
at least 256.

As stdin is a stream and there is no exemption for stdin in the
above, an implementation that does not support lines of at least
254 characters on stdin is non-conformant.

But:

Nothing says how the backspace (or esc, or DEL etc.) keys are to be
handled. This means that there need not be any input line editing
ability. getc() simply returns the next character from that
stream. No buffer is needed. If the user wants a buffer, just
provide it. And ask your system documentation about how to get raw
input.

The fact that users normally want line editing is of no interest.
 
R

Richard Tobin

Suppose a bar-code reader produces data in the form of a short
sequence of digits followed by a linefeed. Surely attaching this to
my computer in such a way that it can be used as standard input
doesn't render my C compiler non-conformant?
[/QUOTE]
However, in such cases, it would not be the *operating system* that
limited the input size below the mandated 254, it would be the
input device's inability to produce additional characters.

The location of the boundary between operating system and device is
irrelevant to the conformance of the C implementation. if you contrive
to provide a long line on standard input, the C system will handle it.
That you can't do that by some particular method is none of the C
standard's business.

Do you think the compiler would be non-conformant if there weren't any
terminal devices?

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top