question about array out of bound index

V

venkatesh

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

Artie Gold

venkatesh said:
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
 
A

Andrew Poelstra

venkatesh said:
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)
 
V

Vladimir Oka

venkatesh said:
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>
 
B

Ben C

venkatesh said:
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.
 
F

Flash Gordon

Ben said:
venkatesh said:
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
 
K

Keith Thompson

Flash Gordon said:
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.
 
R

Richard G. Riley

Default User said:
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.
 
C

CBFalconer

Richard G. Riley said:
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/>
 
D

Default User

CBFalconer said:
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
 
C

CBFalconer

Default said:
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/>
 
R

Rod Pemberton

CBFalconer said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top