Xref: utzoo comp.lang.c:35010 comp.os.msdos.programmer:2638 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!yoyo.aarnet.edu.au!sirius.ucs.adelaide.edu.au!levels!marwk From: marwk@levels.sait.edu.au Newsgroups: comp.lang.c,comp.os.msdos.programmer Subject: Re: Turbo C far pointer problem Message-ID: <15797.2781f6d3@levels.sait.edu.au> Date: 2 Jan 91 15:05:55 GMT References: <1990Dec31.035801.26785@lingua.cltr.uq.OZ.AU> Organization: Sth Australian Inst of Technology Lines: 29 > int maxrows, maxcols; > char **array; > > maxrows = ...whatever... > maxcols = ...whatever... > > array = (char **) malloc(maxcols * sizeof(char *)); Use maxrows in the above line. > > for(x=0; x < maxrows; x++) /* !!! do not change this line */ > array[x] = (char *) malloc(maxrows); Use maxrows in the above line Your first malloc allocates MAXCOLS column pointers. The second allocates MAXROWS rows for MAXROWS columns, not MAXCOLS columns. The usual matrix use requires array[r][c] to refer to the r'th row and the c'th column - the changes above will fix this. Perhaps your UNIX program has a bug it in now? ;-) I have tested my solution with TC 2.01. Ray