Category : C++ Source Code
Archive   : C_ALL.ZIP
Filename : TI803.ASC

 
Output of file : TI803.ASC contained in archive : C_ALL.ZIP







PRODUCT : C++ NUMBER : 803
VERSION : All
OS : PC DOS
DATE : August 12, 1992 PAGE : 1/1

TITLE : Dynamically Allocated Multidimensional Arrays




#include
#include

#define ROW 10
#define COLUMN 15

typedef int ARRAYTYPE;
typedef ARRAYTYPE * ARRAYTYPEPTR;

/* Declare the 2D array as a pointer to a pointer to
ARRAYTYPE */
/* Note there is no memory allocated for the array yet.
*/

ARRAYTYPEPTR *array;

void main()
{
int i, j;

/* First, allocate an array of pointers to ARRAYTYPE of ROW
*/
/* elements. Next, looping through the array of pointers,
*/
/* allocate arrays of ARRAYTYPE of COLUMN elements and
assign */
/* them to the pointers. This assigns the necessary memory
to */
/* the array, which you can then index via the [] operators.
*/

array = (ARRAYTYPEPTR *) malloc (ROW * sizeof(ARRAYTYPEPTR));
for (i = 0; i < ROW; i++)
array[i] = (ARRAYTYPEPTR) malloc (COLUMN * sizeof
(ARRAYTYPE));

/* Fill array with unique values */

for (i = 0; i < ROW; i++)
for (j = 0; j < COLUMN; j++)
array[i][j] = (COLUMN * i) + j;

/* Print out array to make sure everything's OK */














PRODUCT : C++ NUMBER : 803
VERSION : All
OS : PC DOS
DATE : August 12, 1992 PAGE : 2/1
TITLE : Dynamically Allocated Multidimensional Arrays




for (i = 0; i < ROW; i++) {
for (j = 0; j < COLUMN; j++)
printf("%4d",array[i][j]);
putchar('\n');
}
}

DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.








































  3 Responses to “Category : C++ Source Code
Archive   : C_ALL.ZIP
Filename : TI803.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/