Re: pointer q
- From: "Joe Smith" <grumpy196884@xxxxxxxxxxx>
- Date: Mon, 15 May 2006 16:03:38 -0400
"Flash Gordon" <spam@xxxxxxxxxxxxxxxxxx>
Joe Smith wrote:
"RSoIsCaIrLiIoA" <zz@xxxx> wrote in message
news:9odg62tc13dv6m60mlsq19h4caf5ff06ij@xxxxxxxxxx
[snip]
#include <stdio.h>
int main ( void )
{long l = 420000;
long *lp = &l;
short *sp;
*sp = (short)*lp; /* ill-advised, but Let's Pretend */
This is very different. If you were trying to fix the code further up soHow thick is my head ^ ?
it would compile what you wanted was:
short *sp = (short*)*lp; /* ill-advised, but Let's Pretend */
I sometimes mistake the one table for the other![snip]Try it on both big and little endian systems, you can even do it with a
pencil and paper if you don't have both, you will then see the very
different results.
As a general rule casting is a bad idea. There are a few places where it
is required,
As to the syntax on the printf, I've done
everything short of Dedekind cuts on table B-1 and am still pulling out
my hair.
printf is relatively simple, it is scanf that is tricky! If you want to
ask specific questions about printf where you can't understand your text
book I'm sure someone will answer them.
Sounds like something that, according to fashion, merits a huge investment.I'm afraid that I don't know what Bugtraq is ... probably at my own
peril.
Basically a database of bugs.
Am I not reading, with correction, the number that a smaller type thinks aAm I correct to think that a type of masking occurs here? joe
No, not masking. More a case of only reading part of the data with my
"fix". Or with your code writing to an uninitialised pointer and causing
half of your socks to migrate to Alaska.
larger type was? My socks are well accounted for, but Scott Knuds not only
flew out of my hard drive, but is eating my lunch.
BTW, I would not place too much face in anything posted by RSoIsCaIrLiIoA.He sounds like a dude, so you can be assured that I won't give him face, but
A Google search and seeing how often it has posted assembler will show you
why many people probably have it kill filed.
until otherwise motivated, I'll give him the benefit of the doubt. Thanks
for your reply. Joe
.
- Follow-Ups:
- Re: pointer q
- From: Flash Gordon
- Re: pointer q
- From: CBFalconer
- Re: pointer q
- References:
- pointer q
- From: Joe Smith
- Re: pointer q
- From: Keith Thompson
- Re: pointer q
- From: Joe Smith
- Re: pointer q
- From: Eric Sosman
- Re: pointer q
- From: RSoIsCaIrLiIoA
- Re: pointer q
- From: Joe Smith
- Re: pointer q
- From: Flash Gordon
- pointer q
- Prev by Date: Re: switch why?
- Next by Date: Re: Question c faq
- Previous by thread: Re: pointer q
- Next by thread: Re: pointer q
- Index(es):
Relevant Pages
|