🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3679

Re: Help: How to determine big/little endian?

#3679
From: Frank DENIS (Jedi/Sector One)
Date: Tue, 08 Aug 1995 11:28
18 lines
1108 bytes
You might try something like :

   short a = 0x1234;
   
   if (*((char *) &a + sizeof(short) - 1) == 0x34)
     type = BIG_ENDIAN;
   else
     type = LITTLE_ENDIAN;

Jedi.
-- 
`-=[Frank DENIS] aka [JEDI from SECTOR ONE] (HP 48, PC, Unix Code & Music)=-'
< root@the_one.epita.fr & denis_r@epita.edu -=- http://www.epita.edu/~denis_r >
 Internet is not wide enough to keep all the love I still got for you, Fanou
Ring now : THE 0NE BBS (+33) 149 887 691 / N0 Ratio for Long Distance Callers
Minitel: RTC-ONE (1) 48 70 10 29 - (1) 48 58 46 17 - 3615 CYRIELLE - 3615 TR
   ...  "Programming Will Never Feature Your Machine. Learn Coding."  ...
Technical Details
Message-ID: <407hp9$mjv@boson.epita.fr>
Path: arc1-ca.pugleaf.net!boson.epita.fr!cation!denis_r
References: <40762c$nh7@masala.cc.uh.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!boson.epita.fr!cation!denis_r
From: denis_r@epita.fr (Frank DENIS (Jedi/Sector One))
Newsgroups: comp.std.c
Subject: Re: Help: How to determine big/little endian?
Date: 8 Aug 1995 11:28:41 GMT
Organization: Epita (French engineering school)
Distribution: world
Message-ID: <407hp9$mjv@boson.epita.fr>
References: <40762c$nh7@masala.cc.uh.edu>
NNTP-Posting-Host: cation.epita.fr
Function: KrAzY k0dEr
X-newsreader: XRN SunLight