Path: utzoo!mnetor!tmsoft!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!rutgers!maverick.ksu.ksu.edu!ux1.cso.uiuc.edu!uxa.cso.uiuc.edu!sasg0244 From: sasg0244@uxa.cso.uiuc.edu (Steven Arthur Sivier) Newsgroups: comp.lang.c Subject: 2d arrays Summary: dynamic 2d array allocation Message-ID: <1991Mar13.183807.23254@ux1.cso.uiuc.edu> Date: 13 Mar 91 18:38:07 GMT Sender: usenet@ux1.cso.uiuc.edu (News) Organization: University of Illinois at Urbana Lines: 21 i've always tried to avoid 2d arrays, but because of a library function i need to call i need to use 2d arrays. the problem is i have to malloc the 2d array. can i just malloc the array to a char pointer and then use it as a 2d array? that is, if the array has dimensions x by y can i use: char *array; array = malloc(x * y); array[0][0] = 'a' also, inasmuch as i need to pass this array to a library function, can i just send the pointer even though the function expects a 2d array? sorry if this seems like a stupid question, but i usually just kludge around the very few times i've needed multi-dimensional arrays. thanks steve sivier sasg0244@uxa.cso.uiuc.edu