Problem with scanf()/gets()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • subratasinha2006@yahoo.co.in

    Problem with scanf()/gets()

    I can not accept a string (without space) of length more than 127
    whatever I do..

    Entry is restricted by 127 characters.

    I have declared an array of size more than 200.
    or
    I have used dynamic memory allocation.

    But the echo is stopped
  • Mark Bluemel

    #2
    Re: Problem with scanf()/gets()

    subratasinha200 6@yahoo.co.in wrote:
    I can not accept a string (without space) of length more than 127
    whatever I do..
    >
    Entry is restricted by 127 characters.
    >
    I have declared an array of size more than 200.
    or
    I have used dynamic memory allocation.
    >
    But the echo is stopped
    Sounds like a limit in the input buffer size provided by your operating
    system, not a C language/library issue.

    Comment

    • Richard Heathfield

      #3
      Re: Problem with scanf()/gets()

      Mark Bluemel said:
      subratasinha200 6@yahoo.co.in wrote:
      >I can not accept a string (without space) of length more than 127
      >whatever I do..
      >>
      >Entry is restricted by 127 characters.
      >>
      >I have declared an array of size more than 200.
      >or
      >I have used dynamic memory allocation.
      >>
      >But the echo is stopped
      >
      Sounds like a limit in the input buffer size provided by your operating
      system, not a C language/library issue.
      If that's allowed by the Standard, what is the minimum such maximum input
      buffer size? If none is stated, it effectively means that even hosted
      implementations effectively don't have to provide stdin, since they can
      simply set the input buffer size to 0, rendering it impossible to read
      anything in!

      In other words, I think you're wrong - if the implementation is truly
      behaving as described, it sounds non-conforming to me. But I will
      cheerfully point out that I'm not sure of my ground.

      It's at times like this that I'm tempted to shout "CHRISSSSS! !!"

      --
      Richard Heathfield <http://www.cpax.org.uk >
      Email: -http://www. +rjh@
      Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
      "Usenet is a strange place" - dmr 29 July 1999

      Comment

      • Walter Roberson

        #4
        Re: Problem with scanf()/gets()

        In article <1tCdnQ0Gxu81 Z-HanZ2dnUVZ8vKdn Z2d@bt.com>,
        Richard Heathfield <rjh@see.sig.in validwrote:
        >If that's allowed by the Standard, what is the minimum such maximum input
        >buffer size? If none is stated, it effectively means that even hosted
        >implementation s effectively don't have to provide stdin, since they can
        >simply set the input buffer size to 0, rendering it impossible to read
        >anything in!
        That would be contrary to the requirement to allow at least one
        character of ungetc pushback.
        --
        "Any sufficiently advanced bug is indistinguishab le from a feature."
        -- Rich Kulawiec

        Comment

        • fred.l.kleinschmidt@boeing.com

          #5
          Re: Problem with scanf()/gets()

          On Jan 3, 6:24 am, subratasinha2.. .@yahoo.co.in wrote:
          I can not accept a string (without space) of length more than  127
          whatever I do..
          >
          Entry is restricted by 127 characters.
          >
          I have declared an array of size more than 200.
          or
          I have used dynamic memory allocation.
          >
          But the echo is stopped
          Without showing us the code, there is no way we can find the problem.
          --
          Fred Kleinschmidt

          Comment

          • Richard Heathfield

            #6
            Re: Problem with scanf()/gets()

            Walter Roberson said:
            In article <1tCdnQ0Gxu81 Z-HanZ2dnUVZ8vKdn Z2d@bt.com>,
            Richard Heathfield <rjh@see.sig.in validwrote:
            >>If that's allowed by the Standard, what is the minimum such maximum input
            >>buffer size? If none is stated, it effectively means that even hosted
            >>implementatio ns effectively don't have to provide stdin, since they can
            >>simply set the input buffer size to 0, rendering it impossible to read
            >>anything in!
            >
            That would be contrary to the requirement to allow at least one
            character of ungetc pushback.
            No, it wouldn't, because of the "as if" rule - you'd never be able to tell
            that it hadn't been pushed back! :-)

            --
            Richard Heathfield <http://www.cpax.org.uk >
            Email: -http://www. +rjh@
            Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
            "Usenet is a strange place" - dmr 29 July 1999

            Comment

            • Richard Tobin

              #7
              Re: Problem with scanf()/gets()

              In article <2ca9f6a7-1e78-4763-9e62-c0ac775d8247@i2 9g2000prf.googl egroups.com>,
              <subratasinha20 06@yahoo.co.inw rote:
              >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.

              -- Richard
              --
              :wq

              Comment

              • CBFalconer

                #8
                Re: Problem with scanf()/gets()

                Richard Heathfield wrote:
                Mark Bluemel said:
                >subratasinha200 6@yahoo.co.in wrote:
                >>
                >>I can not accept a string (without space) of length more than
                >>127 whatever I do..
                >>>
                >>Entry is restricted by 127 characters.
                >>>
                >>I have declared an array of size more than 200.
                >>or
                >>I have used dynamic memory allocation.
                >>>
                >>But the echo is stopped
                >>
                >Sounds like a limit in the input buffer size provided by your
                >operating system, not a C language/library issue.
                >
                If that's allowed by the Standard, what is the minimum such
                maximum input buffer size? If none is stated, it effectively
                means that even hosted implementations effectively don't have
                to provide stdin, since they can simply set the input buffer
                size to 0, rendering it impossible to read anything in!
                Where does it say that stdin has to be editable on input?

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

                Comment

                • Walter Roberson

                  #9
                  Re: Problem with scanf()/gets()

                  In article <pe6dnej2Os7j n-DaRVnyjQA@bt.co m>,
                  Richard Heathfield <rjh@see.sig.in validwrote:
                  >Walter Roberson said:
                  >In article <1tCdnQ0Gxu81 Z-HanZ2dnUVZ8vKdn Z2d@bt.com>,
                  >Richard Heathfield <rjh@see.sig.in validwrote:
                  >>>If that's allowed by the Standard, what is the minimum such maximum input
                  >>>buffer size? If none is stated, it effectively means that even hosted
                  >>>implementati ons effectively don't have to provide stdin, since they can
                  >>>simply set the input buffer size to 0, rendering it impossible to read
                  >>>anything in!
                  >That would be contrary to the requirement to allow at least one
                  >character of ungetc pushback.
                  >No, it wouldn't, because of the "as if" rule - you'd never be able to tell
                  >that it hadn't been pushed back! :-)
                  You are allowed to ungetc() a character that has not actually
                  been read, and when you read from that stream you must get that
                  character. Therefore stdin must be provided, even if the
                  functionality is only the equivilent of having stdin connected
                  to /dev/null
                  --
                  "There are some ideas so wrong that only a very intelligent person
                  could believe in them." -- George Orwell

                  Comment

                  • mrdarrett@gmail.com

                    #10
                    Re: Problem with scanf()/gets()

                    On Jan 3, 6:24 am, subratasinha2.. .@yahoo.co.in wrote:
                    I can not accept a string (without space) of length more than 127
                    whatever I do..
                    >
                    Entry is restricted by 127 characters.
                    >
                    I have declared an array of size more than 200.
                    or
                    I have used dynamic memory allocation.
                    >
                    But the echo is stopped

                    what OS, what compiler?

                    Comment

                    • Walter Roberson

                      #11
                      Re: Problem with scanf()/gets()

                      In article <flj0q3$30k5$2@ pc-news.cogsci.ed. ac.uk>,
                      Richard Tobin <richard@cogsci .ed.ac.ukwrote:
                      >In article <2ca9f6a7-1e78-4763-9e62-c0ac775d8247@i2 9g2000prf.googl egroups.com>,
                      <subratasinha20 06@yahoo.co.inw rote:
                      >>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.
                      --
                      "I was very young in those days, but I was also rather dim."
                      -- Christopher Priest

                      Comment

                      • Walter Roberson

                        #12
                        Re: Problem with scanf()/gets()

                        In article <1tCdnQ0Gxu81 Z-HanZ2dnUVZ8vKdn Z2d@bt.com>,
                        Richard Heathfield <rjh@see.sig.in validwrote:
                        >Mark Bluemel said:
                        >Sounds like a limit in the input buffer size provided by your operating
                        >system, not a C language/library issue.
                        >If that's allowed by the Standard, what is the minimum such maximum input
                        >buffer size? If none is stated, it effectively means that even hosted
                        >implementation s effectively don't have to provide stdin, since they can
                        >simply set the input buffer size to 0, rendering it impossible to read
                        >anything in!
                        C89 4.9.2 "Streams", Environmental Limits, indicates 254 minimum
                        for text streams (including newline.)
                        --
                        We regret to announce that sub-millibarn resolution bio-hyperdimensiona l
                        plasmatic space polyimaging has been delayed until the release
                        of Windows Vista SP2.

                        Comment

                        • Chris Dollin

                          #13
                          Re: Problem with scanf()/gets()

                          Richard Heathfield wrote:
                          It's at times like this that I'm tempted to shout "CHRISSSSS! !!"
                          C has no namespaces, so that's an ambiguous reference. Also note
                          what Pterry has to say about multiple exclamation marks ...

                          I note the OP hasn't gifted us with their code, so if he's doing
                          something wrong, we have to use our crystal balls to see it. It
                          is seldom good news.

                          --
                          Tough Guide Hedgehog
                          "We did not have time to find out everything we wanted to know."
                          - James Blish, /A Clash of Cymbals/

                          Comment

                          • Richard Heathfield

                            #14
                            Re: Problem with scanf()/gets()

                            Walter Roberson said:
                            In article <1tCdnQ0Gxu81 Z-HanZ2dnUVZ8vKdn Z2d@bt.com>,
                            Richard Heathfield <rjh@see.sig.in validwrote:
                            >>Mark Bluemel said:
                            >
                            >>Sounds like a limit in the input buffer size provided by your operating
                            >>system, not a C language/library issue.
                            >
                            >>If that's allowed by the Standard, what is the minimum such maximum input
                            >>buffer size? If none is stated, it effectively means that even hosted
                            >>implementatio ns effectively don't have to provide stdin, since they can
                            >>simply set the input buffer size to 0, rendering it impossible to read
                            >>anything in!
                            >
                            C89 4.9.2 "Streams", Environmental Limits, indicates 254 minimum
                            for text streams (including newline.)
                            Ah, thank you. (I looked, but couldn't find it.)

                            So it seems that, if the OP's report is correct, his implementation has a
                            conformance issue.

                            --
                            Richard Heathfield <http://www.cpax.org.uk >
                            Email: -http://www. +rjh@
                            Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                            "Usenet is a strange place" - dmr 29 July 1999

                            Comment

                            • Richard Heathfield

                              #15
                              Re: Problem with scanf()/gets()

                              Chris Dollin said:
                              Richard Heathfield wrote:
                              >
                              >It's at times like this that I'm tempted to shout "CHRISSSSS! !!"
                              >
                              C has no namespaces, so that's an ambiguous reference.
                              The One True Chris knows which one I mean. :-)
                              Also note
                              what Pterry has to say about multiple exclamation marks ...
                              Yes, but at least I stopped two short of bursarity.

                              <snip>

                              --
                              Richard Heathfield <http://www.cpax.org.uk >
                              Email: -http://www. +rjh@
                              Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                              "Usenet is a strange place" - dmr 29 July 1999

                              Comment

                              Working...