Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!seismo!rochester!cornell!batcomputer!hsgj From: hsgj@batcomputer.UUCP Newsgroups: comp.lang.c Subject: Need help with pointer to array[][] Message-ID: <132@batcomputer.tn.cornell.edu> Date: Sat, 7-Feb-87 19:57:44 EST Article-I.D.: batcompu.132 Posted: Sat Feb 7 19:57:44 1987 Date-Received: Mon, 9-Feb-87 02:07:55 EST Organization: Theory Center, Cornell U., Ithaca NY Lines: 24 Keywords: two-dim arrays An application I have requires an array to hold filenames. Each element of this array must be 32 chars long, and I would like 16 elements. I used to be using: static char fnames[16][32]; However, I decided it would be better to malloc this space instead of having it static. How do I declare a pointer to a two-d array? My new version is: char *fnames; /* What is correct declaration? */ fnames = malloc(16*32); GetFileNames(fnames); for (i = 0; i < 16; i++) printf("%s\n",fnames[i*32]); /* this is wrong, no? */ I am sure that this is bad practice, and would like to be informed of the 'correct' way to do this. ==> If you are kind enough to reply, please do so via mail. <== ==> This is because I am quite far behind in comp.lang.c. <== -- Dan Green -- ARPA: hsgj%vax2.ccs.cornell.edu@cu-arpa.cs.cornell.edu UUCP: ihnp4!cornell!batcomputer!hsgj BITNET: hsgj@cornella