Yes it does matter, however most *nix systems these days are running x86 processors so should have the same results, assuming that they have the same size word. That said, most *nix systems are 64-bits any longer, so you might want to specify a long long int (64-bits) instead of a simple int (32-bits).
no , i haven't tested on both types of systems. but will the ouptput differ if i run this code on different machines ? that mean i will get highest bits firstly on big-endian and lowest bits firstly on little endian ? right ?
The program, as written, will invoke undefined behavior and most likely not depend on endianness at all.
num+1 produces a pointer that points to the address that num points to plus sizeof(int). You then cast that pointer to char* and dereference it. Since num+1 points outside of the bounds of the object that num points to, this is undefined behavior. In practical terms this will most likely give you the byte that is stored in memory after a. What that byte is will not really depend on endianness.
I assume what you meant to do is *(((char *)num)+1). That is cast num to char* first and then add 1 to it, producing a pointer to the second byte of a.