Re: byte order



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

callbackFoo(pval);

...

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

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

Hi,
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
bruno_nos_pam_van_dooren@xxxxxxxxxxx
Remove only "_nos_pam"


.



Relevant Pages

  • swap using pointers
    ... int swap; ... incompatible pointer type ...
    (comp.lang.c)
  • 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. ...
    (comp.lang.c)
  • 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. ...
    (comp.lang.c)
  • 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 ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Memory Structure Pointer Problems
    ... typedef struct sta { ... char* name; ... int num_cmpnds; ... A pointer to a struct cmp is almost ...
    (comp.lang.c)