HI,
I was wondering if there's no standard library, how many lines of code would it take to do something like printf() ? And is it really possible to program all the functions using the set of C keywords?
HI,
I was wondering if there's no standard library, how many lines of code would it take to do something like printf() ? And is it really possible to program all the functions using the set of C keywords?
// moved... [from the DOS board where nobody but me visites...] i wondered this myself... i'd think not i guess, but can a more knowledgable person respond? thanks!
hasafraggin shizigishin oppashigger...
If you are programming in Windows and don't have windows.h, you need 10,000 lines of code.
Yoshi
Umm.... without a library, you can't hardly do anything. You could sort and search, but that's just about it.
I suppose you could use inline assembly, but that's not C.
That said, printf()... well, if you want to just print a string, then that's less than 100 lines of assembly. If you want it to be able to handle conversion characters and variable length argument lists, then you're looking at something of a monster.
Callou collei we'll code the way
Of prime numbers and pings!
gcc is an open source compiler. Look at the source yourself to see how things are done. A lot of the standard functions are incredibly simple.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
I can tell you from first-hand experience of OS development that it is possible to program most of the libc (the standard C library) in 100% C.
There are some functions that you must use inline assembly (such as the port I/O routines), but for the most part C can be used.
And just for the record, printf() can and is (at least in my OS) programmed entirely in <100 lines of pure C (no inline assembly whatsoever).
I hope that scratches your itch.
>then that's less than 100 lines of assembly<
It's less than 15 lines of C, my friend.
>If you want it to be able to handle conversion characters and variable length argument lists, then you're looking at something of a monster.<
Not really. A stripped version of printf() can be programmed in a couple of lines of C (okay more than a couple) and a header.
For the few of you whom are overly interested in the libc and printf() and implementing these, you can check out this page:
http://www.execpc.com/~geezer/osd/libc/index.htm
Last edited by Hillbillie; 01-28-2002 at 11:30 AM.