Re: little endian or big endian ???
- From: John Bode <john_bode@xxxxxxxxxxx>
- Date: Tue, 03 Jul 2007 08:47:56 -0700
On Jun 29, 6:51 am, Spade <strangerdr...@xxxxxxxxx> wrote:
On Jun 29, 3:22 pm, r...@xxxxxxxxxxxxxxxxxxxxxx (Richard Bos) wrote:
Tejas Kokje <binarysemaph...@xxxxxxxxx> wrote:
On Jun 28, 12:01 pm, guthena <r4r...@xxxxxxxxx> wrote:
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
Congratulations. You just did his homework for him. Since it's a crappy
assignment,
This most probably isn't a homework question. Its a typical question
thats asked mostly in interviews in India.
Which makes it all the more depressing, both that an interviewer would
bother to ask it and that the candidate would need help finding the
answer. If you don't at least have a rough idea of how to figure this
out by the time you're looking for a job, you shouldn't be looking for
a job yet.
As worded, though, this sounds like a typical intro programming
assignment.
his teacher probably thinks he did a sterling job, he'll
probably pass the course on the back of your work, and he'll end up
holding a job as a programmer _still_ thinking that this is a good
program. Which it is not; it is flawed for several reasons.
Can you tell me how it is flawed? Is it because of casting from int*
to char*
It would miss weird things like VAX floats, which were "middle-
endian" (byte order 2301).
.
- Prev by Date: C tricky problem or gcc preprocessor bug ???
- Next by Date: Re: Newbie Question
- Previous by thread: Re: little endian or big endian ???
- Next by thread: C tricky problem or gcc preprocessor bug ???
- Index(es):
Relevant Pages
|