On Thu, Jan 14, 2010 at 6:08 PM, Rotary Engine <
rotaryeng@earthlink.netwrote:
When I compile this extremely simple program I get this cryptic error:
"warning: passing argument 1 of ?printf? from incompatible pointer type"
Here is the program.
# include <stdio.h
int main()
{
printf(stdout, "this is a test\n");
}
What ever could be wrong? :)
Paul Lamar
It's a warning, not an error. There is a difference. Code that
generates compile warnings sometimes runs properly, depending on what
you want to do with it.
I believe in this case, stdout is extraneous.. stdout is the "file"
printf normally prints to.
Do a "man printf" in a shell terminal (linux, right). I think you'll
see that the first argument of printf is const char.. fprintf (and
others) allow redirecting the output to other streams.
Most (maybe all) standard library c functions have man pages on unix hosts.
Regards,
Matt-
Also, if you really want to learn the guts of c programming, I
strongly recommend K&R The C Programming Language..
http://en.wikipedia.org/wiki/The_C_Programming_Language_(book)
This is quite possibly the best written text book I have ever read.
It has concise examples for danged near anything you could want to do
with the c language. It's not frilly, and it doesn't have large
chunks of example code, but all of the fundamental concepts are there
without any distracting garbage.
Matt-
Yes I have that one. I have 7 old books on C and one new one called
Essential Linux Device Drivers published in 2008. The Kernighan
and Ritchie book was published in 1978. I took a course in
C about 20 years ago so I am a bit rusty.
Thanks for the advice Matt.
Paul Lamar
--
The Rotary Engine NewsLetter. Powered by Linux.
ACRE NL web site.
http://www.rotaryeng.net
Youtube key word UTUBPLEASE
Copyright 1998-2009 All world wide rights reserved.