Take FREE!! Online AMCAT Mock Test to Crack Wipro NLTH, Capgemini, etc.
Get Off-Campus Placement Jobs Info !!!
Practice Given Here Wipro NLTH Practice Q&A

Program Discussion :: Bitwise Operator

Home > Programs > Bitwise Operator

8 / 15

Write an efficient program to convert a given number from little endian to big endian

Answer:

#include 
 #include
using namespace std;
/* function to show bytes in memory, from location start to start+n*/
void show_mem_rep(char *start, int n) 
{
    int i;
    for (i = 0; i < n; i++)
         printf(" %.2x", start[i]);
    printf("\n");

/*Main function to call above function for 0x01234567*/
int main()
{
   int i = 0x01234567;   show_mem_rep((char *)&i, sizeof(i));
   getchar();
   return 0;
}

Asked In ::

Post Your Answer Here:

Language:

Post Your Reply Here:



Language:

Post Your Reply Here:



Language:

Post Your Reply Here: