-
Sizeof question...
How do I get the size of the data a pointer is referencing?
Ex:
LPBYTE pRawData = NULL;
pRawData = SomeFuncThatReturnsPtrToData();
//Now how to I get the size of the DATA pRawData is pointing to?
-
Re: Sizeof question...
"CT" <CT@yahoo.com> wrote:
>
>How do I get the size of the data a pointer is referencing?
>
>Ex:
>
>LPBYTE pRawData = NULL;
>
>pRawData = SomeFuncThatReturnsPtrToData();
>
>//Now how to I get the size of the DATA pRawData is pointing to?
>
Hi CT
Try
int sizeofdata=sizeof(*pRawData);
Try and reply:-)
-
Re: Sizeof question...
If pRawData is a NULL terminated text string,
you can use strlen() to get the length. If
it is binary data, you will have to use some
other method, i.e. a priori knowledge or some
custom parsing routine.
NOTE: sizeof() will not work. It will return
the length of a pointer, probably 4 bytes.
Wayne
"CT" <CT@yahoo.com> wrote:
>
>How do I get the size of the data a pointer is referencing?
>
>Ex:
>
>LPBYTE pRawData = NULL;
>
>pRawData = SomeFuncThatReturnsPtrToData();
>
>//Now how to I get the size of the DATA pRawData is pointing to?
>
-
Re: Sizeof question...
"R W Collymore" <software1@technologist.com> wrote in message
news:38e08ecf$1@news.devx.com...
> >LPBYTE pRawData = NULL;
> >
> >pRawData = SomeFuncThatReturnsPtrToData();
> int sizeofdata=sizeof(*pRawData);
That is almost certainly not going to respond with the value he is
looking for. Assuming that LPBYTE is a "long pointer to a BYTE", then
"sizeof(*pRawData)" would be exactly the same as "sizeof(BTYE)". sizeof is
*always* resolved at compile-time, so it can never take into consideration a
run-time value.
--
Truth,
James Curran
http://www.NJTheater.com
http://www.NJTheater.com/JamesCurran
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks