hello to all,

i am learning c++ and while looking at some code, i came upon this: *(float*) and
*(DWORD*).
for example

#define adress_1 0x00AA8B20
*(float*) adress_1 = 5000000;

so can you explain what the *(float*) and *(DWORD*) do.

and i did try and search on google but didnt get very far

Recommended Answers

All 2 Replies

This casts 0x00AA8B20 to a pointer to float and dereferences it.
So it interprets 0x00AA8B20 as an address of a float value.
One would normally write this as such:
*reinterpret_cast<float*>(0x00AA8B20)=5000000;

DWORD is just a typedef to (u)int or (u)long.

That is very common when programming hardware in C and the addresses are known. They could be static I/O or similar.

address_1 is 0x00AA8B20,
(float*) address_1 would interpret the address as a pointer to a float and
* (float*) address_1 then means the variable stored at that address.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.