byte representation of program objects

Can someone help me with this topic " byte representation of program objects" using pointers in Cpp

I dont know how to make it in cpp
Thanks in advance

Leo2505 (1)
Can someone help me with this topic " byte representation of program objects" using pointers in Cpp

I dont know how to make it in cpp
Thanks in advance
---------------------------------------------------------------------------------

a char is a byte. Most prefer unsigned, but it makes no real difference to the computer.
you can cast any pointer type to another.
eg
uint64_t i{};
char *cp = (char*)&i; //have to cast it to the new type else is error
sprintf(cp,"hello");
cout << i;

you can do this to anything, but complex objects that contain pointers give you the POINTER not the DATA.
struct oops
{
string s; //taking the address of an oops object will NOT safely get you the string's text data. Its off under another pointer. you just get the bytes of the address of that location.
int i;
}
to deal with that you have to go into each sub-object and break it out until you have all the pieces you need.
Last edited on
Registered users can post here. Sign in or register to post.