Re: entering more characters



On 27 Jul 2005 05:15:31 -0700, "Barry" <prbharath@xxxxxxxxx> wrote in
comp.lang.c:

1. Stop top posting.

> Why don't u do a bounce check? never get past an array limit

2. Don't post nonsense.

-- 'u' doesn't post here anymore, we kicked him out.

-- C doesn't have anything called a "bounce check".

-- There is no way to stop scanf "%s" without a length value from
overflowing a small buffer. On some implementations, there is no way
to prevent it from overflowing any size buffer.

> kk wrote:
> > Hi all,
> >
> > in the following code, i enter more characters into a character array.
> > array size declared as 80. i enter more characters then i get
> > segmentation fault. if anybody knows give me reply.
> > thanks in advance.
> >
> > Regards
> > kk
> >
> >
> > main()
> > {
> > char s[80];
> > scanf("%[^\n]s",s);
> > printf("%s",s);
> > }

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
.



Relevant Pages

  • Re: Would this be safe?
    ... > a array of characters, to enable me to send the ... > to always try to avoid buffer overflows especially when dealing ... Many languages provide runtime support for guarding against such ...
    (alt.comp.lang.learn.c-cpp)
  • Re: user input, getchar, and buffer - For C beginners and those with teaching skills...
    ... buffer: video streaming, printer jobs. ... > Fgets unlike scanf has a limit in the number of caracters ... to read any newline left (here it would be located in array> "chaine" ... than 20 characters and keeps it in the buffer? ...
    (comp.lang.c)
  • Re: Best way to input from stdin?
    ... // read the buffer ... A quick google on the subject failed to return any meaningful result and searching this group's history through google groups ended up being a very disappointing experience (a search for nothing more than "stdin" returns only 14 results that only go as far as June 8th). ... and where it is OK to discard any characters beyond that length, ... then there is a string in the array. ...
    (comp.lang.c)
  • Re: string manipulation
    ... I'll assume that buffer points to a string buffer, i.e., to an ... doesn't allow array assignment. ... the nth through n+mth characters. ... target to become a copy of the specified substring? ...
    (comp.lang.c.moderated)
  • Re: "test.c:20: error: expected identifier before =?UTF-8?B?4oCYKOKAmQ==?= token"
    ... I'm trying to create a buffer that holds an array of characters. ...
    (comp.lang.c)