Click to See Complete Forum and Search --> : How to get the size of a pointer for LPSTR?


September 7th, 1999, 04:26 AM
I would like to get the size of the whole data in lpSTR in the following
after I insert some 'data' into data.

int *data = new int[100];
LPSTR lpStr;
lpStr = (LPSTR) data; //I am trying to convert the 'int'data to 'LPSTR'data.
// is this correct ?
//insert data
delete [] data;

What is the command for obtaining the size of lpStr ?
Please help me!
I would like to appreciate your help in advance.

ALM
September 7th, 1999, 08:24 AM
The size of lpStr is based on the number of integers you put into data (0 to 100) multiplied by the size of an integer (4 bytes).

Alvaro

PeterK
September 7th, 1999, 11:25 AM
#define MAXINT 100

int *data = new int[MAXINT];
LPSTR lpStr;
lpStr = (LPSTR) data;

int tmp = sizeof(data);
int tmp2 = sizeof(lpStr);

// both tmp and tmp2 will equal 4, the size of a pointer (not the size of data that is being pointed at).

// so one way to figure the size out would be something like this:

int tmp3 = sizeof(data) * MAXINT;

delete [] data;




I am curious as to what you are going to use the lpStr variable for.