[Coco] glork!!!

Manny cocolist at invigorated.org
Mon Dec 17 13:01:19 EST 2007


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.)

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. :)

If there any source to his libs?

-M.



More information about the Coco mailing list