From: Patrick Percot <ppercot@free.fr>
To: ankitjain1580@yahoo.com
Cc: gcc-help@gcc.gnu.org, linux-c-programming@vger.kernel.org
Subject: Re: Static memory allocation
Date: Fri, 24 Sep 2004 14:51:13 +0200 (CEST) [thread overview]
Message-ID: <20040924.145113.74752222.ppercot@free.fr> (raw)
In-Reply-To: <20040924105708.5067.qmail@web52904.mail.yahoo.com>
On Fri, 24 Sep 2004 11:57:08 +0100 (BST), Ankit Jain <ankitjain1580@yahoo.com> 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
--
Groupe Morbihannais d'Utilisateurs de Logiciels Libres http://www.tuxbihan.org
GPG fingerprint = 1A4F E154 3D2C A20E E4CA A543 7951 C5C2 E44A A0B5
Patrick Percot.
next prev parent reply other threads:[~2004-09-24 12:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-24 10:57 Static memory allocation Ankit Jain
2004-09-24 12:51 ` Patrick Percot [this message]
2004-09-25 9:14 ` Ankit Jain
2004-09-25 21:51 ` Patrick Percot
2004-09-25 10:03 ` Jon Masters
-- strict thread matches above, loose matches on Subject: below --
2004-09-24 14:21 Huber, George K RDECOM CERDEC STCD SRI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040924.145113.74752222.ppercot@free.fr \
--to=ppercot@free.fr \
--cc=ankitjain1580@yahoo.com \
--cc=gcc-help@gcc.gnu.org \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).