TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:10678] Simple C Question



Thank you everyone, I knew I was just missing something stupid...

Wonderful how you can over-think a problem, isn't it?

The %d idea works perfectly....

Brian

>>> rgoldber@d.umn.edu 12/01/99 10:51AM >>>
Hmm, you're casting ints to addresses, I'm suprised it doesn't
segfault.
Use %d and get rid of the cast.  Or, if you really want these ints to
be
strings, look at sprintf()

-ryan           be kind.

On Wed, 1 Dec 1999, Brian Ackermann wrote:

> Ok, simple question for all you C programmers out there...
> 
> Here's the line of code in question...
> 
> printf("%s\n", (char *)(FO_Offset+=16));
> 
> Assuming FO_Offset=0 at start and this code runs in a loop we should
> see:
> 
> 16
> 32
> 48
> 64
> 80
> 96
> 
> and so on...
> 
> I'm assuming that (FO_Offset+=16) evaluates to an integer value,
say,
> 16, in
> the first instance,
> and then casting it to a (char *) will let the printf() do what it
> does.
> 
> The program compiles without errors or warnings, but the text is
just
> garbage...
> 
> What am I missing?
> 
> Thanks in advance,
> Brian J. Ackermann
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe@mn-linux.org 
> For additional commands, e-mail: tclug-list-help@mn-linux.org 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tclug-list-unsubscribe@mn-linux.org 
For additional commands, e-mail: tclug-list-help@mn-linux.org