HOWTO: Create Two-dimensional Huge Arrays w/ C++ new OperatorLast reviewed: August 26, 1997Article ID: Q133067 |
The information to this article applies to:
SUMMARYThe code sample in this article shows two ways to dynamically create huge two-dimensional arrays (bigger than the 64K byte limit) using the C++ new operator. One method shows the proper use of the __huge keyword for 16-bit compilers. For more information on creating a two-dimensional array (with a size less than 64K bytes), please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q102391 TITLE : HOWTO: Create Two-Dimensional Arrays with Operator new MORE INFORMATIONHere are two methods you can use to create a large two-dimensional array. The first method, for the 16-bit compiler, shows the proper use of the __huge keyword. The second method needs a special compiler option for a 16-bit Windows-based application.
First Method Sample CodeA pointer to an array of the elements to be created is to be declared First as follows:
/* For 16-bit compiler */
/* No special compile options needed. */
#include <iostream.h>
void main(void)
{
char (__huge *varchar)[350]; // Declare pointer to an
// array of 350 characters.
varchar = new __huge char[130000][350]; // Pointer declaration and
// the initialization have
// to be on separate lines.
/* Application code */
delete [] varchar;
}
Second Method Sample Code
/* Use the Huge memory model compiler option with the 16-bit compiler */
void main(void)
{
char (*varchar )[350];
varchar = new char [130000][350];
/* Application code */
delete [] varchar;
}
The second method can be used in Visual C++ versions 2.0 and 2.1 without
using any compiler option.
|
Additional query words: 8.0 8.0c 8.00 8.00c
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |