Re: Why multiplication not allowed?
From: Sean Kenwrick (skenwrick_at_hotmail.com)
Date: 01/07/04
- Next message: August Derleth: "Re: Why in hash function use 5381?"
- Previous message: August Derleth: "Re: Why in hash function use 5381?"
- In reply to: Joona I Palaste: "Re: Why multiplication not allowed?"
- Next in thread: Joona I Palaste: "Re: Why multiplication not allowed?"
- Reply: Joona I Palaste: "Re: Why multiplication not allowed?"
- Reply: Richard Heathfield: "Re: Why multiplication not allowed?"
- Reply: Lew Pitcher: "Re: Why multiplication not allowed?"
- Reply: CBFalconer: "Re: Why multiplication not allowed?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 7 Jan 2004 13:56:13 +0000 (UTC)
"Joona I Palaste" <palaste@cc.helsinki.fi> wrote in message
news:btf1cq$22o$1@oravannahka.helsinki.fi...
> Sean Kenwrick <skenwrick@hotmail.com> scribbled the following:
> > Your solution above is correct but can you figure out why the following
code
> > is invalid (which it is):
>
> > *k = *k/*j;
>
> > assuming k and j are pointers to ints that have been correctly
> > initialized....
>
> Are you testing our knowledge? The C tokeniser thinks of the /* as the
> start of a comment, so it ends up being:
> *k = *k
> which is a syntax error because the lack of a terminating semicolon.
> Were you thinking of using it in some way like this?
> *k = *k/*j; /* make sure the value of *k stays in bounds */
> +0; /* this is just a dummy */
Yeah you got it. By dividing *k by *j (without spaces) you get a syntax
error.
*k=*k/*j;
you get a syntax error because the /* starts a comment. I was given this
as a question in an interview for a job when I was a student (and I didn't
get the question right (or the job!)).
But I think the reason I didn't get the job was because one of the other
questions the interviewer asked me was to tell him what was wrong with the
following statement:
i=+i;
I said that there was nothing wrong with it, but the interviewer claimed
that it was an ambiguous statement because it could mean adding i to itselt
or setting i to +i. I got into an argument with him saying that he must
be confused with i+=i; but he was adament he was right and got annoyed that
I was disagreeing wih him.
Afterwards I wondered whether this might have been some kind of syntax left
over from a very early incarnation of C which was subsequently dropped.
Perhaps the members of this group could enlighten me about this since I
think that this guy was just a complete idiot.
The last question he asked was for me to declare a pointer to a funtion that
returned a pointer to a function that returned a pointer to a char.
Needless to say, without my K&R book to hand I messed that up as well (but
by now I got the feeling that this guy was just being mean).
In the end they gave the job to a female friend of mine who by her own
admission was not a great programmer (she got me to do all her programming
assignments in return for her doing all my essay assignments).
Sean
- Next message: August Derleth: "Re: Why in hash function use 5381?"
- Previous message: August Derleth: "Re: Why in hash function use 5381?"
- In reply to: Joona I Palaste: "Re: Why multiplication not allowed?"
- Next in thread: Joona I Palaste: "Re: Why multiplication not allowed?"
- Reply: Joona I Palaste: "Re: Why multiplication not allowed?"
- Reply: Richard Heathfield: "Re: Why multiplication not allowed?"
- Reply: Lew Pitcher: "Re: Why multiplication not allowed?"
- Reply: CBFalconer: "Re: Why multiplication not allowed?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|