Mail Archives: djgpp/1999/06/09/17:44:26
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 -