Re: byte order

int* p = new int[10];
int pval=(int)p;



callbackFoo(int pval)
int* p=(int*)pval;

int ppp=pval[0]; ///Error the byte order are upsidedown.

Why do you cast the pointer to an int?
The code you show does not cause any byte swapping by itself.
Is the int passed to a DLL built with another language or something? And
where does the callback function come from?


Kind regards,
Bruno van Dooren
Remove only "_nos_pam"


Relevant Pages

  • swap using pointers
    ... int swap; ... incompatible pointer type ...
  • Re: Reading a string of unknown size
    ... "Don't cast return value of malloc() in C. ... It is entirely possible for an int to be returned by a ... function using a different method than that used to return a pointer. ...
  • Re: Is this code valid
    ... | the program, or a null pointer, or a pointer to non-modifiable ... is promoted to `unsigned int'. ... implementations), the cast is therefore necessary. ...
  • Re: A little help please
    ... >>You don't need the cast. ... void* to another pointer type. ... if arr points to first element of int array then I thought by ...
  • Re: Memory Structure Pointer Problems
    ... typedef struct sta { ... char* name; ... int num_cmpnds; ... A pointer to a struct cmp is almost ...