delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/13/09:30:32

From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: array-problem
Date: Sun, 13 Jun 1999 00:56:23 -0400
References: <7jmecs$sbl$1 AT nnrp1 DOT deja DOT com>
X-Posted-Path-Was: not-for-mail
X-Accept-Language: en
X-ELN-Date: 13 Jun 1999 04:55:06 GMT
X-ELN-Insert-Date: Sat Jun 12 22:05:02 1999
Organization: Nocturnal Aviation
Lines: 50
Mime-Version: 1.0
NNTP-Posting-Host: 1cust232.tnt11.nyc3.da.uu.net
Message-ID: <376339F7.A21D4C10@earthlink.net>
X-Mailer: Mozilla 4.6 [en] (Win95; U)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

perryr8461 AT my-deja DOT com wrote:
> 
> Hello,
> I have some problems with the following code:
[...]
> 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?

#include <stdio.h>

int main(void)
{
    int num_m, num_n, i, q;
    int m[128][128];
    printf("m=");
    fflush(stdout);             /* mha - you really should do this */
    scanf("%d", &num_m);
    printf("n=");
    fflush(stdout);             /* mha - you really should do this */
    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);
#if 0
            /* mha - had you allowed gcc to do so, it would have told  
             *  you of the following line 
             a.c:15: warning: format argument is not a pointer (arg 2) 
             *  a correction follows */
            scanf("%d", m[i][q]);
#endif
            fflush(stdout);     /* mha - you really should do this */
            scanf("%d", &m[i][q]);
        }
    }
    printf("\n");               /* mha - omit this at your own peril */
    return 0;
}



/* vi: set cindent ts=4 sw=4 et tw=72: */

-- 
Martin Ambuhl (mambuhl AT earthlink DOT net)

Ah! but it is something to have at least the 
choice of nightmares.  - Joseph Conrad

- Raw text -


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