Write a small C program to determine whether a machine's type is
little-endian or big-endian. 23 14185
On Jun 28, 12:01 pm, guthena <r4r...@gmail.c omwrote:
Write a small C program to determine whether a machine's type is
little-endian or big-endian.
It's a FAQ.
guthena wrote, On 28/06/07 20:01:
Write a small C program to determine whether a machine's type is
little-endian or big-endian.
Save yourself the trouble and use a machine where char, short, int and
long are all the same size.
Alternatively, do your own homework. Once you've posted your attempt
someone might help you with it.
--
Flash Gordon
In article <11************ *********@j4g20 00prf.googlegro ups.com>,
guthena <r4****@gmail.c omwrites
>Write a small C program to determine whether a machine's type is little-endian or big-endian.
When does this homework have to be completed by?
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys. org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
guthena wrote On 06/28/07 15:01,:
Write a small C program to determine whether a machine's type is
little-endian or big-endian.
This small C program handles other possibilities, too:
#include <stdio.h>
int main(void){int q=puts("Enter 1 for big-endian or"
" 2 for little-endian: ");fflush(0);sw itch(q=scanf(
"%d",&q)>0?q:0) {defualt:puts(" mixed-endian");break;
case 1:puts("big-endian");break; defau1t:puts("o ther"
"-endian");break; case 2:puts("little-endian");break;
default:puts("a nti-endian");break; }return q?!q:q;}
Enjoy!
-- Er*********@sun .com
guthena <r4****@gmail.c omwrites:
Write a small C program to determine whether a machine's type is
little-endian or big-endian.
Why?
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
On Jun 28, 12:01 pm, guthena <r4r...@gmail.c omwrote:
Write a small C program to determine whether a machine's type is
little-endian or big-endian.
Here you go..
int main()
{
int num=1;
char *cptr;
cptr = (char *)#
if (*cptr)
printf ("little endian\n");
else
printf ("big endian\n");
return 0;
}
Which company interview question is this ? :-D
Tejas Kokje
guthena wrote:
Write a small C program to determine whether a machine's type is
little-endian or big-endian.
No, thank you. Why are you giving out assignments?
guthena wrote:
Write a small C program to determine whether a machine's type is
little-endian or big-endian.
OK, I've done that.
--
Chris "it'ss /mine/, preciousss" Dollin
Hewlett-Packard Limited registered no:
registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: hicham |
last post by:
Hi,
I am looking for help, i would like to know how can i use the endian.h and
config.h to convert compiled files under solaris from BIG-ENDIAN to compiled
files LITTLE-ENDIAN.
I am working under linux debian 3.0 woody
Thank you for your help.
|
by: gary |
last post by:
Hi,
1. About all C/C++ compilers, Does stack increase from high address to low address and heap grow increase from low to high? What on earth decides their increase direction, CPU architecture, OS or compiler?
2. In GNU gcc,
{
int a = {0, 1, 2, 3, 4};
bool b;
float c;
for (int i = 0; i < 5; i++) {
|
by: Perception |
last post by:
Hello all,
If I have a C-like data structure such that
struct Data {
int a; //16-bit value
char; //3 ASCII characters
int b; //32-bit value
int c; //24-bit value
}
|
by: bhatia |
last post by:
Hello all,
If I have a C-like data structure such that
struct Data {
int a; //16-bit value
char; //3 ASCII characters
int b; //32-bit value
int c; //24-bit value
}
|
by: manishster |
last post by:
I keep getting the following in my output file , regardless of whether
I convert endian-ness or not . How do i get "01 02 03 04" ....
Mahamannu
output : 04 03 02 01 b0 00 00
| |
by: RRick |
last post by:
This was a question that showed up in a job interview once. (And to answer your next question: No, I didn't :))
Write a subroutine that returns a bool on whether a system supports big endian numbers (true) or little endian (false). I tried something like the following, but never did find out if it was correct.
There are two assumptions here: First, big endian direction from small to large is ordered like a string. Second, endian is...
|
by: Javier |
last post by:
Hello people,
I'm recoding a library that made a few months ago, and now that I'm
reading what I wrote I have some questions.
My program reads black and white images from a bitmap (BMP 24bpp
without compression). It has it's words and dwords stored in little-
endian, so I do a conversion to big-endian when reading full words or
dwords.
I have done this because my system is big-endian.
But now... what if one compiles the library in a...
|
by: Ramesh |
last post by:
Hi
I have a structure as below on big endian based system
typedef struct
{
unsigned long LedA:5;
unsigned long LedB:4;
unsigned long LedC:8;
|
by: Niranjan |
last post by:
I have this program :
void main()
{
int i=1;
if((*(char*)&i)==1)
printf("The machine is little endian.");
else
printf("The machine is big endian.");
}
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |