question about array out of bound index

Discussion in 'C Programming' started by venkatesh, Apr 27, 2006.

  1. venkatesh

    venkatesh Guest

    hai
    I need to know about array out of bound error which is thought by
    our lecturer .she thought that when u gross the intialially specified
    size it will show that error,but when I am working on my computer it
    shows only the value which is allocated after the declaration?
     
    venkatesh, Apr 27, 2006
    #1
    1. Advertising

  2. venkatesh

    Artie Gold Guest

    venkatesh wrote:
    > hai
    > I need to know about array out of bound error which is thought by
    > our lecturer .she thought that when u gross the intialially specified
    > size it will show that error,but when I am working on my computer it
    > shows only the value which is allocated after the declaration?
    >

    Standard C has no facilities for bounds checking on arrays; when you
    exceed the bounds of an array you invoke the dreaded UB -- undefined
    behavior -- at which point *anything* can happen. If you're lucky your
    program crashes in a way that's easy to diagnose. If you're not...well,
    beware of nasal demons!

    (Please see the FAQ.)

    HTH,
    --ag

    --
    Artie Gold -- Austin, Texas
    http://goldsays.blogspot.com
    "You can't KISS* unless you MISS**"
    [*-Keep it simple, stupid. **-Make it simple, stupid.]
     
    Artie Gold, Apr 27, 2006
    #2
    1. Advertising

  3. venkatesh wrote:
    > hai
    > I need to know about array out of bound error which is thought by
    > our lecturer .she thought that when u gross the intialially specified
    > size it will show that error,but when I am working on my computer it
    > shows only the value which is allocated after the declaration?
    >


    I'm really not sure what you're saying.

    int aarray[10]; is the same as
    int *parray = malloc(10);

    sizeof (aarray) should be the same as sizeof (parray)

    --
    Andrew Poelstra <http://www.wpsoftware.net/blog>
    Every prime number in a series as a joke
    Made all the patterns clear when I took that final toke
     
    Andrew Poelstra, Apr 27, 2006
    #3
  4. venkatesh

    Vladimir Oka Guest

    venkatesh wrote:
    > hai
    > I need to know about array out of bound error which is thought by
    > our lecturer .she thought that when u gross the intialially specified
    > size it will show that error,but when I am working on my computer it
    > shows only the value which is allocated after the declaration?


    Reading past the end of an array is not allowed, but the Standard does
    not require this to be detected or reported. The Standard does
    guarantee that incrementing a pointer to point just one past the end of
    an array will not overflow. Going further leads to Undefined Behaviour.
    Either way, you're still not allowed to dreference such a pointer
    (that's UB as well).

    <OT>
    Some C implementations offer so called "bounds checking" as an
    extension, usually in the form of a compile time option. Turning this
    on tends to produce larger and slower code, as extra code is included
    to check every indexed access to the array.
    </OT>
     
    Vladimir Oka, Apr 27, 2006
    #4
  5. venkatesh

    Ben C Guest

    On 2006-04-27, Andrew Poelstra <> wrote:
    > venkatesh wrote:
    >> hai
    >> I need to know about array out of bound error which is thought by
    >> our lecturer .she thought that when u gross the intialially specified
    >> size it will show that error,but when I am working on my computer it
    >> shows only the value which is allocated after the declaration?
    >>

    >
    > I'm really not sure what you're saying.
    >
    > int aarray[10]; is the same as
    > int *parray = malloc(10);
    >
    > sizeof (aarray) should be the same as sizeof (parray)


    No not at all. sizeof aarray == 10 * sizeof (int), sizeof parray ==
    sizeof (int *).

    On a typical 32-bit machine the sizes are 40 and 4.
     
    Ben C, Apr 27, 2006
    #5
  6. venkatesh

    Flash Gordon Guest

    Ben C wrote:
    > On 2006-04-27, Andrew Poelstra <> wrote:
    >> venkatesh wrote:
    >>> hai
    >>> I need to know about array out of bound error which is thought by
    >>> our lecturer .she thought that when u gross the intialially specified
    >>> size it will show that error,but when I am working on my computer it
    >>> shows only the value which is allocated after the declaration?
    >>>

    >> I'm really not sure what you're saying.
    >>
    >> int aarray[10]; is the same as
    >> int *parray = malloc(10);
    >>
    >> sizeof (aarray) should be the same as sizeof (parray)

    >
    > No not at all. sizeof aarray == 10 * sizeof (int), sizeof parray ==
    > sizeof (int *).
    >
    > On a typical 32-bit machine the sizes are 40 and 4.


    Correct.

    Venkatesh should read the comp.lang.c FAQ starting at
    http://c-faq.com/aryptr/constptr.html followed by the rest of section 6
    then the rest of the FAQ.
    --
    Flash Gordon, living in interesting times.
    Web site - http://home.flash-gordon.me.uk/
    comp.lang.c posting guidelines and intro:
    http://clc-wiki.net/wiki/Intro_to_clc

    Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
     
    Flash Gordon, Apr 27, 2006
    #6
  7. Flash Gordon <> writes:
    [...]
    > Venkatesh should read the comp.lang.c FAQ starting at
    > http://c-faq.com/aryptr/constptr.html followed by the rest of section
    > 6 then the rest of the FAQ.


    Just one note about the FAQ:

    The front page, <http://www.c-faq.com/> says:

    [Note to web authors, catalogers, and bookmarkers: the URL
    <http://www.c-faq.com/> is the right way to link to these
    pages. All other URL's implementing this collection are subject to
    change.]

    I usually post the base URL of the FAQ plus a question number, both
    for this reason and because it could encourage people to look around
    if they see other sections and questions while navigating to the one I
    point them to.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Apr 27, 2006
    #7
  8. venkatesh

    venkatesh Guest

    tahnk you for your kind of information about the arry out of bound
    index error
     
    venkatesh, Apr 30, 2006
    #8
  9. venkatesh

    Default User Guest

    venkatesh wrote:

    > tahnk you for your kind of information about the arry out of bound
    > index error


    Who are you talking to? See below.



    Brian

    --
    Please quote enough of the previous message for context. To do so from
    Google, click "show options" and use the Reply shown in the expanded
    header.
     
    Default User, Apr 30, 2006
    #9
  10. "Default User" <> writes:

    > venkatesh wrote:
    >
    >> tahnk you for your kind of information about the arry out of bound
    >> index error

    >
    > Who are you talking to? See below.
    >


    He was replying to Artie Gold. But then you would have know that if you
    could use your multi column thread display in online/offline mode in
    xananews. He was thanking him for his help actually.

    Do you not get heartily sick of posting the same insipid nitpicking
    rebuke day after bloody day? I know most people would.
     
    Richard G. Riley, May 2, 2006
    #10
  11. venkatesh

    CBFalconer Guest

    "Richard G. Riley" wrote:
    > "Default User" <> writes:
    >> venkatesh wrote:
    >>
    >>> tahnk you for your kind of information about the arry out of bound
    >>> index error

    >>
    >> Who are you talking to? See below.

    >
    > He was replying to Artie Gold. But then you would have know that
    > if you could use your multi column thread display in online/offline
    > mode in xananews. He was thanking him for his help actually.
    >
    > Do you not get heartily sick of posting the same insipid nitpicking
    > rebuke day after bloody day? I know most people would.


    Yes, we do. However until we can shame, or otherwise persuade
    google to stop doing the damage it is to usenet, we can only
    attempt to inform the ignorant who have been trapped by the foolish
    google interface. That is one reason I attempt to collect the
    necessary information in a slightly oversize sig. Foolish people
    who mutter and moan about the giving of necessary information to
    newbies are probably a net negative value to the world.

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
    More details at: <http://cfaj.freeshell.org/google/>
    Also see <http://www.safalra.com/special/googlegroupsreply/>
     
    CBFalconer, May 2, 2006
    #11
  12. venkatesh

    Default User Guest

    CBFalconer wrote:

    > "Richard G. Riley" wrote:
    > > "Default User" <> writes:


    > > Do you not get heartily sick of posting the same insipid nitpicking
    > > rebuke day after bloody day? I know most people would.

    >
    > Yes, we do.



    Sorry to piggyback on your message, but I'll remind Riley that I
    killfiled him for trolling on Tues, Feb 21 2006 5:25 pm (according to
    Google).



    Brian
     
    Default User, May 2, 2006
    #12
  13. venkatesh

    CBFalconer Guest

    Default User wrote:
    > CBFalconer wrote:
    >> "Richard G. Riley" wrote:
    >>> "Default User" <> writes:

    >
    >>> Do you not get heartily sick of posting the same insipid nitpicking
    >>> rebuke day after bloody day? I know most people would.

    >>
    >> Yes, we do.

    >
    > Sorry to piggyback on your message, but I'll remind Riley that I
    > killfiled him for trolling on Tues, Feb 21 2006 5:25 pm (according to
    > Google).


    That's all right. I had it in the sin bin, but let it out again
    some time ago. I just reenergized that particular filter. I will
    hear no more from it.

    --
    "If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers." - Keith Thompson
    More details at: <http://cfaj.freeshell.org/google/>
    Also see <http://www.safalra.com/special/googlegroupsreply/>
     
    CBFalconer, May 2, 2006
    #13
  14. "CBFalconer" <> wrote in message
    news:...
    > Default User wrote:
    > > CBFalconer wrote:
    > >> "Richard G. Riley" wrote:
    > >>> "Default User" <> writes:

    > >
    > >>> Do you not get heartily sick of posting the same insipid nitpicking
    > >>> rebuke day after bloody day? I know most people would.
    > >>
    > >> Yes, we do.

    > >
    > > Sorry to piggyback on your message, but I'll remind Riley that I
    > > killfiled him for trolling on Tues, Feb 21 2006 5:25 pm (according to
    > > Google).

    >
    > That's all right. I had it in the sin bin, but let it out again
    > some time ago. I just reenergized that particular filter. I will
    > hear no more from it.
    >
    > --


    Rodenborn,

    You seem to think it has some sort of meaning to say you 'killfiled'
    someone. Noone cares if you killfile someone.
    You haven't contributed anything of value to any group since 1995. And,
    enough people do provide an appropriate response that you're completely
    irrelevant.

    Falconer,

    You didn't contributed anything of value to any group from 1995 to 2005.
    I'll make an exception for 2006.


    So tell me you two, just how does it feel to post nothing but 'Troll
    complaints' for roughly decade?


    Rod Pemberton
     
    Rod Pemberton, May 4, 2006
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sunil panda

    Lower bound & Upper bound

    sunil panda, Dec 25, 2003, in forum: Java
    Replies:
    9
    Views:
    7,359
    thushara wijeratna
    Oct 7, 2008
  2. Rhiner Dan
    Replies:
    1
    Views:
    774
    Mike Wahler
    Mar 27, 2005
  3. Mario Krsnic
    Replies:
    0
    Views:
    400
    Mario Krsnic
    Jun 23, 2006
  4. Sanjeev
    Replies:
    0
    Views:
    465
    Sanjeev
    Jun 30, 2008
  5. Tomasz Chmielewski

    sorting index-15, index-9, index-110 "the human way"?

    Tomasz Chmielewski, Mar 4, 2008, in forum: Perl Misc
    Replies:
    4
    Views:
    362
    Tomasz Chmielewski
    Mar 4, 2008
Loading...

Share This Page