Re: Static memory allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, Patrick,

Actually the original post of this program referred to a[1449][0] element only. I guess it was a typo this time from Ankit (and that was the reason I did not bother to go through the program again). Anyway, Claudio's answer did clear most of the fog.

Cheers,
Harsha.

Patrick Percot wrote:

On Fri, 24 Sep 2004 11:57:08 +0100 (BST), Ankit Jain <ankitjain1580@xxxxxxxxx> wrote



hi



Hi,



well i had tried to enquire about this problem

i was not able to find the solution. i know it workds
when i declare the array globally. i know if i use
malloc it will work and i am using the same in my
program

but this question is again in my mind that what could
be the reason that it dosent work here on my system
because last time when i asked this question on some
sytem it was able to run which they said that they
have less emory then that of my system

my system config.: redhat linux 9.0 +512 RAM
this is what my terminal displays

[ankit@Ankit fft]$ cat try2.c
#include <stdio.h>
int main()
{
double a[1450][1450];
a[1450][0]=999.999;



You do not just have a stack problem : The upper bound is not 1450, but
1449, because the first index is 0.


So  a[1449][0] has  more chances  to  work correctly,  but the  problems
generated  by  such a  fault  can be  insidious  and  very difficult  to
discover, because the error can appear later in your program.



printf("%lf\n",a[1450][0]);
return 0;
}
[ankit@Ankit fft]$ gcc try2.c
[ankit@Ankit fft]$ ./a.out
Segmentation fault
[ankit@Ankit fft]$

i just want to know that if there is some problem
related to stack how t oget rid of it

thanks

ANkit




________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now http://uk.messenger.yahoo.com/download/index.html





À+
PP


begin:vcard
fn:Sriharsha Vedurmudi
n:Vedurmudi;Sriharsha
org:Redpine Signals Inc.;Software
adr:Sagar Society, Road #2, Banjara Hills;;Gate #395, Plot # 87, 88;Hyderabad;Andhra Pradesh;500034;India
email;internet:sriharsha.v@xxxxxxxxxxxxxxxxxx
title:Software Engineer
tel;work:+91-40-23559911
tel;cell:+91-9849133133
x-mozilla-html:TRUE
url:http://www.redpinesignals.com
version:2.1
end:vcard


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux