[Coco] glork!!!

Gene Heskett gene.heskett at verizon.net
Mon Dec 17 11:39:01 EST 2007


On Monday 17 December 2007, Willard Goosey wrote:
>Anybody ever notice that the Kreider C lib "printf" returns really
>strange values?

Its always worked for me.

>Yes, I know I can't expect ANSI compliance (which is to return the
>number of charaters printed) but "return 0 on sucess, -1 on failure"
>IS proper K&R behavior.
>
>I was throwing together a quick yes(1) to help with using deldir in a
>shell script, and was about to post it here, when I thought, "I'd
>better try it under OS-9 just to make sure it works...."
>
>The sad thing is, I'd written a yes(1) long ago, I think it's on rtsi,
>and it works.... because the printf() just *happens* to return a
>positive number the way it was called.
>
>Specifically, ..printf("foo bar\n") returned -79xxx and
>... printf("%s\n","foo bar") returns 31744!
>
>Very very strange.
>
>Willard

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.

-- 
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)
Since we have to speak well of the dead, let's knock them while they're alive.
		-- John Sloan



More information about the Coco mailing list