** help...
Jim Dunn
nol2321 at dsacg2.dsac.dla.mil
Tue Aug 21 07:37:39 AEST 1990
Well, no one took me up on my offer of checking out the Curses Source I've
been working on, so I'll ask a "more direct and specific" question...
Why can't I do the following?!? (C'mon you gurus...)
---Cut Here---
#include <stdio.h>
typedef struct _window {
int x;
int y;
int **array;
int beg_x;
int beg_y;
int max_x;
int max_y;
} WINDOW;
main()
{
int x, xL = 10;
WINDOW *w1;
w1 = (WINDOW *) malloc(sizeof(WINDOW));
/* the problem is next */
w1->array = malloc( xL * sizeof(int) );
/* isn't the above line legal, or how can I allocate mem for the storage */
for(x=0;x < xL; x++)
w1->array[x] = (int *) malloc( 10 * sizeof(int *) );
}
This is setup for, let's say, a 10 x 10 matrix of ints, OK?
It'll compile ok, but it'll lock up the machine... (at least on the PC).
Jim
jdunn at dsac.dla.mil
More information about the Comp.lang.c
mailing list