Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!dsinc!cs.widener.edu!sven From: sven@cs.widener.edu (Sven Heinicke) Newsgroups: comp.lang.c Subject: struct {int **i}; problem Message-ID: <1991Mar23.213414.12572@cs.widener.edu> Date: 23 Mar 91 21:34:14 GMT Organization: Widener CS Dept Lines: 58 Nntp-Posting-Host: ashley.cs.widener.edu I got a little double integer pointer in a structure problem while in a subprogram problem. I think I have got everyting but one line down but I am not 100% sure about the malloc() line either. Here is the extract of the code I am working on: . . . struct imatrix { char **board; int size; }; typedef struct imatrix iMATRIX; main() { int l; iMATRIX playing; . . . /* * here are the three malloc() lines I am * not sure work right but I think do. * playing.size is picked bye the user. */ playing.board = (int**)malloc(sizeof(int *) * playing.size * playing.size); for(l = 0;l < playing.size * playing.size;l++) *(playing.board) = (int*)malloc(sizeof(int)); reset(&playing); . . . } reset(matrix) iMATRIX *matrix; { int x,y; for(x = 0;x < matrix->size;x++) for(y = 0;y < matrix->size;y++) (*(matrix->board+x)+y) = x * matrix->size + y + 1; /* * This in the line that I got confused about, * it don't compile. In gnu c it gets the error: * invalid lvalue in assigment * * could somebody tell me what line to use? * */ } -- sven@cs.widener.edu Widener CS system manager Sven Mike Heinicke and Student (pssmheinicke@cyber.widener.edu (if you must))