• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Reading little endian and big endian in objective c
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reading little endian and big endian in objective c


  • Subject: Reading little endian and big endian in objective c
  • From: Waqar Ahmad <email@hidden>
  • Date: Thu, 29 Dec 2011 12:22:27 +0500

Hi,

 

i have an array of hex values

 

unsigned char buffer[]= {ff,ff,0f,02,4b........};

//as ff contains 255 and ffff =65535 and so on..

// char * temppointer=buffer;

 

i want to create a struct

 

typedef struct abc{

u_int32_t a;

u_int16_t b;

u_int64_t c;

u_int32_t d;

char buf[10];

};

 

u_int32_t convertoBigEndian :(u_int32_t tmpint)

{

(u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000000000ffULL) << 56) | \

                                    (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000000000ff00ULL) << 40) | \

                                    (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000000000ff0000ULL) << 24) | \

                                    (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000ff000000ULL) <<  8) | \

                                    (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000ff00000000ULL) >>  8) | \

                                    (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000ff0000000000ULL) >> 24) | \

                                    (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00ff000000000000ULL) >> 40) | \

                                    (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0xff00000000000000ULL) >> 56) )}

 

 

i want create a pointer to buffer[] array and want to pass this pointer to structure abc and want

to read these values like first 4 bytes to a, next 2 bytes to b and so on in little endian and big endian format.

I did this in C# but no idea in MAC so please help me...

 

 

Waqar Ahmad

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Reading little endian and big endian in objective c
      • From: James Bucanek <email@hidden>
References: 
 >Plist (From: Motti Saroka <email@hidden>)

  • Prev by Date: Plist
  • Next by Date: Re: Reading little endian and big endian in objective c
  • Previous by thread: Plist
  • Next by thread: Re: Reading little endian and big endian in objective c
  • Index(es):
    • Date
    • Thread