User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 391,554 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,582 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 1710 | Replies: 11
Reply
Join Date: Dec 2006
Posts: 1,284
Reputation: Aia is a name known to all Aia is a name known to all Aia is a name known to all Aia is a name known to all Aia is a name known to all Aia is a name known to all 
Rep Power: 9
Solved Threads: 88
Aia's Avatar
Aia Aia is offline Offline
Nearly a Posting Virtuoso

Question about Standard C Library.

  #1  
Jan 10th, 2007
Friends, I have a question:

Many times in books and tutorials I'm sent to consult the Standard C Library reference. Sometimes, references are made to some Standard C function.

Where do I see the Standard C Library in a compiler. I don't see any source code in my compiler that shows me for example how printf() or scanf() works. All that I see is header files.
Could anyone show me some light in the matter?. I would like to know how I can learn about the abilities of the functions I'm using, and not just follow like a sheep, what the book tells me to code.
Thank you!.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,542
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 860
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: Question about Standard C Library.

  #2  
Jan 10th, 2007
one place to get the documentation is google man pages.
google man printf

Another place is the links in this thread
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Join Date: May 2006
Location: Bellevue, WA
Posts: 1,548
Reputation: Infarction has a spectacular aura about Infarction has a spectacular aura about Infarction has a spectacular aura about 
Rep Power: 8
Solved Threads: 51
Sponsor
Infarction's Avatar
Infarction Infarction is offline Offline
Battle Programmer

Re: Question about Standard C Library.

  #3  
Jan 10th, 2007
You'll need to be consulting documentation for those. Most of the time, all of those functions will already be compiled into libraries, and your linker will reference the libraries when it puts your program together.
Reply With Quote  
Join Date: Apr 2004
Posts: 3,449
Reputation: Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light 
Rep Power: 16
Solved Threads: 138
Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Question about Standard C Library.

  #4  
Jan 10th, 2007
Originally Posted by Aia View Post
Many times in books and tutorials I'm sent to consult the Standard C Library reference. Sometimes, references are made to some Standard C function.
Perhaps no better place to look is the standard itself -- or at least a publicly available draft thereof.
Reply With Quote  
Join Date: Dec 2006
Posts: 25
Reputation: gabs is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
gabs's Avatar
gabs gabs is offline Offline
Light Poster

Re: Question about Standard C Library.

  #5  
Jan 11th, 2007
Originally Posted by Aia View Post
Friends, I have a question:
I would like to know how I can learn about the abilities of the functions I'm using, and not just follow like a sheep, what the book tells me to code.


how about trying the msdn website? you might not get the source code, but you can find about every function what are it's possible parameters, what values it returns, and many times it even shows examples.

www.msdn.co.il
Reply With Quote  
Join Date: Dec 2006
Posts: 1,284
Reputation: Aia is a name known to all Aia is a name known to all Aia is a name known to all Aia is a name known to all Aia is a name known to all Aia is a name known to all 
Rep Power: 9
Solved Threads: 88
Aia's Avatar
Aia Aia is offline Offline
Nearly a Posting Virtuoso

Re: Question about Standard C Library.

  #6  
Jan 11th, 2007
Thank you for your desire to help me.

@ Dave Sinkula: the link you provided is going to keep me bussy for a while.
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,542
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 860
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: Question about Standard C Library.

  #7  
Jan 11th, 2007
The problem with reading the standard itself is that the standard is written mostly for designers/writers of compilers. New programmer students will probably find it not-too-useful. I would rather read one of the many books you can buy or free e-books, which are written for people actually writing the programs.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Join Date: Dec 2006
Posts: 1,284
Reputation: Aia is a name known to all Aia is a name known to all Aia is a name known to all Aia is a name known to all Aia is a name known to all Aia is a name known to all 
Rep Power: 9
Solved Threads: 88
Aia's Avatar
Aia Aia is offline Offline
Nearly a Posting Virtuoso

Re: Question about Standard C Library.

  #8  
Jan 11th, 2007
You are correct Ancient Dragon. I haven't learned enough to understand
most of what is in there. I'm learning now about functions and what they are, and I'm understanding them. So, I started asking myself about other functions already made, like strlen(), strcpy(), and so forth. But I don't see anywhere the actual code to know how these functions are structured. Same with printf() and scanf().
I guess I'm going to have to take it on faith and use them, even when I'm disappointed to learn that for example scanf() is not very good, for what I was using it for. Makes me wonder what else I learn in books that is not good. Thank goodness I never used gets(). :rolleyes:

I appreciate any help you guys are giving me. Thank you very much.
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,542
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 36
Solved Threads: 860
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: Question about Standard C Library.

  #9  
Jan 11th, 2007
The actual code that implements the functions in stadnard libary are compiler-dependent -- the standards do not dictate how the functions are implemented, only what the functions should do. So one compiler might implement the functions differently then another compiler. You can get the source code for all compiler functions from GNU, which is open-source and free. But be prepared for some really nasty ( ) reading!

Some of the functions, like strlen() are pretty simple. Others, like printf() family of functions, get pretty complicated and difficult for newbes to follow. So I'm not sure how useful the source code would be to you at your level of understanding. Many, if not most, of the functions in the C standard library were written over 20 years ago and tested in thousands, if not millions, of programs. So you can be well assured that they work correctly as designed and documented. This doesn't mean they are good functions to use, just that they work ok.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Join Date: Apr 2004
Posts: 3,449
Reputation: Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light 
Rep Power: 16
Solved Threads: 138
Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Question about Standard C Library.

  #10  
Jan 11th, 2007
Originally Posted by gabs View Post
how about trying the msdn website? you might not get the source code, but you can find about every function what are it's possible parameters, what values it returns, and many times it even shows examples.

www.msdn.co.il
I find the MSDN very difficult to navigate for the appropriate tool. You can be really thrown off into implementation-specific stuff without knowing it. They are getting to be much better, though.
Originally Posted by Ancient Dragon View Post
The problem with reading the standard itself is that the standard is written mostly for designers/writers of compilers. New programmer students will probably find it not-too-useful. I would rather read one of the many books you can buy or free e-books, which are written for people actually writing the programs.
The library section isn't as bad as the rest.

While the standard doesn't have good example for each and every function, it is quite good at telling you exactly what ALL compilers have to do.

Whereas online references and even man pages sometimes tell you implementation-specific stuff too (whether or not you know it is left to the reader).

Or worse:
http://cppreference.com/stdio/printf.html
Can you spot the undefined behavior that is described there, if you implemented what was stated? Do you think a newb has a chance in hell of noticing?
---

So my advice:
  • Try to do something you want to do in code.
  • Look up functions in the standard that you think are appropriate.
  • Post question(s) to forum(s) such as this when things go awry -- after reading said site's FAQ.
Last edited by Dave Sinkula : Jan 11th, 2007 at 9:12 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 9:27 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC