Categories > Coding > C++ >

What is (DWORD*) in C++

Posts: 2

Threads: 2

Joined: Aug, 2022

Reputation: 0

Posted

I am not able to distinguish the effect and difference of Pointer and Address in C++, What is it used for and how to use it correctly, And is it any different when not using Pointer for a variable?

 

My Example:

 

DWORD* Value = (DWORD*)0; //Result = 0000000000000000//

 

vs

 

DWORD Value = 0; //Result = 0//

 

Why does it have more zeros when adding a pointer?

  • 0

Medusa

WeAreTruth

vip

Posts: 148

Threads: 17

Joined: Jul, 2022

Reputation: -29

Replied

In C++, the notation (DWORD*) is a pointer to a data type called DWORD. DWORD stands for Double Word and is used to store a value that's an unsigned 32-bit integer. The * operator before a data type creates a pointer to that data type. So in this case, (DWORD*) creates a pointer to a DWORD. Pointers are commonly used in C++ to keep track of memory addresses, and they can be used to directly manipulate memory, like when working with dynamic memory allocation or other advanced tasks.

  • 1

https://media.discordapp.net/attachments/1064332722065117204/1067596913781784606/Frame_2_1.png

0x90

dingleberry#2286

vip

Posts: 249

Threads: 26

Joined: Dec, 2020

Reputation: 28

Replied

When you output a pointer it gives you sizeof(void*) bytes. If you're on x64 this is 16 digits 

  • 0

Posts: 283

Threads: 48

Joined: May, 2022

Reputation: -4

Replied

@_realnickk

No. Simply not, study where "WORD" came from and you'll understand why DWORD is not 8 bytes on x64 lol, WORD is historically known for being 16 bits, DWORD is always 32 bits on both x86 and AMD64/x86-64. And to answer the guys, question, when you std::cout << ptr, a operator<< overload which takes in a std::ostream& and a const void* will be called which will output a hexadecimal value, for example:

std::cout << reinterpret_cast< DWORD* >( 313231 ) will result in the following output: 000000000004C78F.

There aren't "more zeros", the overload just tries to be accurate with the output instead of outputting it as a regular integer.

 

Also, Nick, your explanation was cloudy at best, I'm not going to bother explaining pointers here as I have already made a tutorial on them but, when you explain concepts your teminology should be at least coherent.

  • 0

Added

@_realnickk

 

Typically it doesn't, most implementations don't change it, though it is standardized that an unsigned long must be at minimum 4 bytes/32 bits, though any implementation can go above that, most don't though. This also goes for other integer data types where short is minimum 16 bits, long is minimum 32 bits, long long is minimum 64 bits.

  • 0

Added

  • 0

https://media.discordapp.net/attachments/1044764388546068510/1051935933836050482/Signature_4.png

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )