delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/09/17:44:26

Sender: root AT delorie DOT com
Message-ID: <375EFC95.6B71BE6F@pmail.net>
Date: Wed, 09 Jun 1999 23:45:25 +0000
From: Fred Backman <fredrick DOT backman AT pmail DOT net>
Organization: http://www.femmefetish.com
X-Mailer: Mozilla 4.5 [en] (X11; I; Linux 2.0.36 i686)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: array-problem
References: <7jmecs$sbl$1 AT nnrp1 DOT deja DOT com>
Reply-To: djgpp AT delorie DOT com

Which one is not working the 16x16 one or 128x128 one, or both?

If you want the dimensions of matrix m to be dynamic (ie num_m x num_n),
I'd suggest you define m as:
int *m;
then after num_m and num_n has been read
m = (int *)malloc(num_m * num_n);

...then set each cell. But this might not be what you had in mind...?


perryr8461 AT my-deja DOT com wrote:

> Hello,
> I have some problems with the following code:
>
> ...
> main()
> {
>     int num_m, num_n,i,q;
>     int m[128][128];
>     printf ("m=");
>     scanf ("%d", &num_m);
>     printf ("n=");
>     scanf ("%d", &num_n);
>     for (i=0;i<num_m;++i)
>     {
>         printf ("\nm#%d\n", i+1);
>         for (q=0;q<num_n;++q)
>         {
>             printf ("n#%d=", q+1);
>             scanf ("%d", m[i][q]);
>         }
>     }
> }
> ...
>
> When I compile it with TurboC and replace int m[128][128] with
> int m[16][16] it runs correctly. But when I compile it with DJGPP
> it aborts. I guess it has something to do with the array m. Does
> somebody know where the bug is?
>
> Greetings,
> David
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019