Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Problem with scanf()/gets()

Reply
Thread Tools

Problem with scanf()/gets()

 
 
CBFalconer
Guest
Posts: n/a
 
      01-04-2008
Walter Roberson wrote:
> Richard Tobin <(E-Mail Removed)> wrote:
>> <(E-Mail Removed)> wrote:

>
>>> I can not accept a string (without space) of length more than
>>> 127 whatever I do..
>>>
>>> Entry is restricted by 127 characters.

>
>> 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.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      01-04-2008
In article <flk0bu$g7j$(E-Mail Removed)>,
Walter Roberson <(E-Mail Removed)-cnrc.gc.ca> wrote:

>>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?


>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
--
:wq
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments