Re: entering more characters
- From: Jack Klein <jackklein@xxxxxxxxxxx>
- Date: Wed, 27 Jul 2005 21:52:39 -0500
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
.
- References:
- entering more characters
- From: kk
- Re: entering more characters
- From: Barry
- entering more characters
- Prev by Date: Re: difficult to code
- Next by Date: Re: Hints on how to migrate from C++ to C
- Previous by thread: Encouraging illegal behavior is O/T in clc (Was: Re: entering more characters)
- Next by thread: Re: entering more characters
- Index(es):
Relevant Pages
|