![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2008
Posts: 2
Rep Power: 0
![]() |
I m curious abt the header files used in C
i tried reading the code in stdio,h for the function scanf but i cant understand anything suggest any source for some info regarding this |
|
|
|
|
|
#2 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 630
Rep Power: 4
![]() |
Re: stdio.h what language is it
Any header files used by C (stdio.h, math.h, stdlib.h, string.h, etc) are all written in C. Where you might be getting confused is that most implementations of the C standard library that I've seen (especially on POSIX systems where there is a lot of added functionality) are extremely complicated.
There are LOTS of macro tricks, compiler tricks (and extensions) and it is generally unreadable. For example, the character class functions are fairly easy to use: c Syntax (Toggle Plain Text)
But if you check its preprocessed output (with gcc -E in my particular case), you'll see a massive file where the entire contents of the stdio.h file and the ctype.h file (as well as some other stuff that I don't pretend to understand) have been included. The actual call to isalpha() was replaced with this: c Syntax (Toggle Plain Text)
I'm pretty sure that the implementation of the character class functions in glibc (the GNU standard C library) is actually a table lookup. If you think that's bad, try looking at the C++ headers. EDIT: I should also mention that the definition for functions will not be in the header files. Header files declare functions so that the compiler and linker will be aware of them. The actual source for a function like scanf will likely not be present on your system. Depending on which platform you're on, you can download the source to your C library and find it. It probably won't be easy to find, though.
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
#3 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 3
![]() |
Re: stdio.h what language is it
>suggest any source for some info regarding this
http://www.amazon.com/Standard-Libra.../dp/0131315099 If you'd like, I can also give you a sample implementation for Windows. It's greatly simplified just so that beginners will have an easier time than with vendor quality implementations.
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Apr 2008
Posts: 2
Rep Power: 0
![]() |
Re: stdio.h what language is it
thnks a lot ppl
and narue plz giv me tht windows impementation u were talking abt |
|
|
|
|
|
#5 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 3
![]() |
Re: stdio.h what language is it
Attached are the source files. Note that all of the standard names that I redefine have been prefixed with 'j' or 'J' to avoid conflicts with your compiler. Other parts of the standard library (such as malloc or the ctype functions) are used as-is with the implementation; I don't redefine them. Finally, I haven't had time to deck out the whole thing with detailed comments and documentation, so you'll have to suffer with the current minimal commenting.
If you don't understand the what, why, or how of any piece of code, feel free to start a thread on it. ![]()
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| If you had it to do all over again, which language? | peace_of_mind | Coder's Corner Lounge | 24 | Jan 13th, 2008 5:06 PM |
| The C programming Language (2nd Edition) | nnxion | Book Reviews | 10 | Jul 6th, 2007 3:29 PM |
| Assembly Language | DaWei | Coder's Corner Lounge | 0 | Apr 26th, 2007 10:15 PM |
| Language creation/extending | gryfang | Project Ideas | 43 | Jul 20th, 2006 1:42 PM |
| Language display in program | Prm753 | C++ | 3 | May 30th, 2006 5:45 PM |