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.
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...