Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bill macleod

macrumors newbie
Original poster
Sep 8, 2006
14
0
Hi.
I accidently found something interesting today. I typed man printf
at the shell prompt and got a pretty big page on using printf. Is this
the equivalent of Java API's, are there pages for the whole C language?
It's pretty cool but, I'm wondering Why? Could someone explain more about this?

Thanks very much,

Bill
 

iMeowbot

macrumors G3
Aug 30, 2003
8,634
0
kingjr3 said:
Unfortunately, the man page you saw was for the shell

There is a printf shell command, but the function also has a man page of its very own.

Operating system call functions are in section 2, and C library stuff in section 3. For the printf() function, try man 3 printf
 

bill macleod

macrumors newbie
Original poster
Sep 8, 2006
14
0
Thanks for your replies.
This is all very interesting to me.
I'm not sure I know what a system call is and I am vaguely familiar
with libraries from 6 weeks of Java. I guess I know the general concept.
I did some googling and found out the C language was written to develop
operating systems, unix in particular. Since OS X is built on BSD, this now
makes a little more sense.

I'm guessing a system call is a function (==to Java method?) that is called
as part of OS operation and they have arguments slightly different than the
same function in the C libraries for writing programs. Is this close? Is that
why there are seperate pages for them?

Could you recommend a book or site that explains how these pieces fit
together, how an OS might depend on libraries? I'm sorry if I sound very
ignorant about all this. My Java class seems to be just teaching how to piece
together code. And there is a lot more I think I should know about how the whole
system functions.

Thanks for your time

bill
 

rtharper

macrumors regular
Sep 6, 2006
201
0
Oxford, UK
bill macleod said:
I'm guessing a system call is a function (==to Java method?) that is called
as part of OS operation and they have arguments slightly different than the
same function in the C libraries for writing programs. Is this close? Is that
why there are seperate pages for them?

Could you recommend a book or site that explains how these pieces fit
together, how an OS might depend on libraries?

bill

A system call is a function that is provided by the operating system that the programmer can all to ask the operating system to do something. These are important because, for both security and ease of use, some things cannot be done directly by the programmer. Printing to the screen or the file is an example. You, as the programmer, are not supposed to have direct access to the video hardware for the screen, or have to tell the hard drive how to write a file. The operating system takes care of all of this, and gives you an interface to ask it do to these things. Hence system calls.

man is a documentation system for Unix. Generally speaking it has an entry for every system call, every command, and every standard unix program (grep, bc, vi, etc.). Other programs add manpages as they are installed so that you can look up more info. If you want to look up entries in a specific section (for example printf() in c and not the shell script function printf), looking how to do so by typing "man man", it's the man page for man itself.

As for what libraries are, they are a group of objects and/or functions grouped to perform a set of similar tasks. If you talked about "packages" in java, this is a good analogy. They are usually grouped together in one file and (in c) used by putting an #import directive in the beginning of the file (or import <package> in Java).

If you want more information about how Operating Systems work, most of the textbooks by Andrew Tannenbaum are pretty good.
 

casperghst42

macrumors regular
Jan 11, 2006
154
101
# man 3 printf
this will give you the right one - man pages consists of diffrent sections (can't remember them), but number 3 is for the C library.

Regards/Casper

bill macleod said:
Hi.
I accidently found something interesting today. I typed man printf
at the shell prompt and got a pretty big page on using printf. Is this
the equivalent of Java API's, are there pages for the whole C language?
It's pretty cool but, I'm wondering Why? Could someone explain more about this?

Thanks very much,

Bill
 

bill macleod

macrumors newbie
Original poster
Sep 8, 2006
14
0
Thank you all, for the thoughtfull replies to my question.
I found Modern Operating Systems by Tannenbaum at the library
and will be digging in shortly. Thanks also for the help on man pages.
I accessed them before, but only in relation to playing around in bash.
I never knew there was so much more.

Thanks again

bill
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.