[Coco] glork!!!

Gene Heskett gene.heskett at verizon.net
Mon Dec 17 18:28:29 EST 2007


On Monday 17 December 2007, Manny wrote:

>Gene Heskett wrote:

>>> Specifically, ..printf("foo bar\n") returned -79xxx and

>>> ... printf("%s\n","foo bar") returns 31744!

>>>

>>> Very very strange.

>>

>> You are leaving out the output format specifier in the first case Willard.

>> Go look up printf in any C reference book. Also, the "foo bar" should

>> point at the defined variables. Either that or bit rot has gotten to your

>> copy...

>>

>> Normal syntax would be:

>>

>> printf("list-of-format-strings\r", nameofvar, nameofvar, etc);

>>

>> That's off the top of my head, but that's how I remember it, having

>> written a bunch of stuff in C.

>

>Both of Willard's examples are perfectly fine for ANSI C. I would

>suspect that the same would be held for K&R C, as well.

>

>An interesting note about the return value of printf in gcc:

>

>printf ("%d\n", printf ("foo bar\n"));

>

>Returns the number of characters that were printed to stdout. (Which

>would be 8 in this case.)


Which, using the above syntax, would appear to be correct. And I think you
would get the same result if a puts("foo bar\n"); was done but its been so
long I won't go anywhere near a bible and say that. :)


>So, unless I've missed the whole point of this post, which I normally

>end up doing, the return values of the printf function is weird. :)

>

I don't think it was the return values, but what it was actually printing, so
his strings were being interpreted as numbers somehow, or at least that is
how I read it.


>If there any source to his libs?


The Kreider libs? I might have some of that on my coco if I can figure out
how to get it up here to this linux box. And if I recognized it when I saw
it. :) I built that trig lib by the south american who sent it to Rainbow
before he died, and I seem to recall I needed to rebuild the Kreider libs
because of a module ordering problem one of my programs had, but that was
close to 20 years ago before I started the fade of advanced years. It may
also be on rsti, I haven't looked there recently.

--
Cheers, Gene
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
It's a lot of fun being alive ... I wonder if my bed is made?!?



More information about the Coco mailing list