int PileInts[1024];
char *Pile = (char *)PileInts;
What do these two lines of code do? I am thinking that the char *Pile = (char *)PileInts; line creates a character named *Pile that gives the value of the address at PileInts. Am I right? Could I get a deeper explanation?
The line
creates an array object that consists of 1024 integers. The object can be accessed using the variable name
PileIntsThe line
creates a char pointer object and makes it point to the first char of the array object. The char pointer object is accessed using the variable name
Pile.The char pointer
Pilecan be used for accessing the individual bytes ofPileInts. Example:Possible output:
Note: The output may differ from system to system due to different endianess and/or integer size.
If you want to see the value of
Pile, i.e. the address it points to, you can change the code like:Possible output: