Turbo C far pointer problem
Jean-Claude Lacherez
jcl at lingua.cltr.uq.OZ.AU
Mon Dec 31 14:58:01 AEST 1990
When I do not have constants to dimension conventional arrays,
e.g. when I want to do dynamic dimensioning, I use the following trick:
int maxrows, maxcols;
char **array;
maxrows = ...whatever...
maxcols = ...whatever...
array = (char **) malloc(maxcols * sizeof(char *));
for(x=0; x < maxrows; x++)
array[x] = (char *) malloc(maxrows);
Thereafter, I can use <array> as a normal 2-dimension array,
like <strcpy(array[x], astring);> or <array[x][y] = achar;>, etc...
Now my problem: This works fine on a Unix system.
Using Turbo C in PC DOS it works fine also as long as I stick to a
small or medium memory model. But it goes wayward with the large
model. It is obvious that it has to do with far pointers. However
I cannot find the logic of it, and after trying all possible (?)
contorsions with type casting I cannot make it work at all.
I would be grateful for any help.
Jean-Claude Lacherez
jcl*lingua.cltr.uq.oz.au
More information about the Comp.lang.c
mailing list