I am using Visual C++ 6.0. When I am trying to allocate memory dynamically for a char*, it is not allocated correctly.
charp = new char;
I can not understand this problem. I am trying to allocate 1 byte. But I am getting size as 4.
Please help me to understand this issue. Thanks in advance.
is a pointer.
A pointer is commonly 4 bytes long.
Therefore, the size of the pointer named charp
If this makes no sense to you, or you don't understand how a pointer can always be 4 bytes long, please read about pointers: http://www.cplusplus.com/articles/EN3hAqkS/
Last edited on
Thanks for your help. Now I can understand the reason.
Actually I am trying to read binary file using char*. If the size of char* is 4 means then how can I read 1 byte or 2 bytes data?
Is there any simple way to do that? or do I need to read all bytes and then split that as per my need?
Thanks for the explanation.