473,396 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

question about array out of bound index

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?

Apr 27 '06 #1
13 2495
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.]
Apr 27 '06 #2
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
Apr 27 '06 #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?


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>

Apr 27 '06 #4
On 2006-04-27, Andrew Poelstra <ap*******@shaw.ca> 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.
Apr 27 '06 #5
Ben C wrote:
On 2006-04-27, Andrew Poelstra <ap*******@shaw.ca> 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
Apr 27 '06 #6
Flash Gordon <sp**@flash-gordon.me.uk> 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) ks***@mib.org <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.
Apr 27 '06 #7
tahnk you for your kind of information about the arry out of bound
index error

Apr 30 '06 #8
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.
Apr 30 '06 #9
"Default User" <de***********@yahoo.com> 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.

May 2 '06 #10
"Richard G. Riley" wrote:
"Default User" <de***********@yahoo.com> 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/>
May 2 '06 #11
CBFalconer wrote:
"Richard G. Riley" wrote:
"Default User" <de***********@yahoo.com> 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
May 2 '06 #12
Default User wrote:
CBFalconer wrote:
"Richard G. Riley" wrote:
"Default User" <de***********@yahoo.com> 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/>

May 3 '06 #13

"CBFalconer" <cb********@yahoo.com> wrote in message
news:44***************@yahoo.com...
Default User wrote:
CBFalconer wrote:
"Richard G. Riley" wrote:
"Default User" <de***********@yahoo.com> 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
May 4 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: JKop | last post by:
template<class T> inline T& NthArrayMember( T & (array),size_t i) { return array; } template<class T> inline const T& NthArrayMember( const T & (array),size_t i) { return array;
5
by: Tarjei Romtveit | last post by:
I'm still a newbie into C++ programming, so I got a quite foolish string related question. Using: Dev-cpp 4.9.9.2 (I think Dev-Cpp uses a gcc compiler of some sort) If i declare a char...
46
by: RoSsIaCrIiLoIA | last post by:
Write a function that gets an array of unsigned int fill it with random values all differents, and sorts it. It should be faster than qsort too. Do you like my solution? _______________________...
4
by: Jason S | last post by:
I haven't been able to find a clear answer to this and I'm hoping someone could enlighten me. As pertains to databinding a control in a repeating fashion(datagrid, repeater, etc.) what event...
8
by: mark | last post by:
I have been modifying an application to enable debugging with Strict ON. I need to use the Array.Copy method and I have encountered an anomaly that I do not understand. I have reproduced the...
8
by: Paul in Toronto | last post by:
Got this assignment in my VB .NET class. The program's basically a picture viewer that lets you add your pictures to an array so you can cycle through them once the file's been opened. So you...
4
by: Ben Voigt | last post by:
I am accustomed to using a pointer to traverse an array in native C++. Here I am trying to copy a slice of a native 2-D array into a managed 2-D array to make it accessible by C#. But piData...
10
by: | last post by:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily complicated than the other languages I know. I feel this is because there aren't many good official resources out there to...
26
by: MLH | last post by:
How would I modify the following to achieve a 2-dimensional array? Dim MyWeek, MyDay MyWeek = Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") ' Return values assume lower bound set to 1...
3
by: Jerry West | last post by:
I'd like to get the upper bound index of an integer array. I've tried the following: Dim i as Integer Dim arrayIng() as Integer i = arrayIng.GetUpperBound This doesn't work. It seems...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.