Imagine there's no standard librrary..

This is a discussion on Imagine there's no standard librrary.. within the A Brief History of Cprogramming.com forums, part of the Community Boards category; HI, I was wondering if there's no standard library, how many lines of code would it take to do something ...

  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020

    Imagine there's no standard librrary..

    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?

  2. #2
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    // 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...

  3. #3
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    If you are programming in Windows and don't have windows.h, you need 10,000 lines of code.
    Yoshi

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    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!

  5. #5
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    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

  6. #6
    Unregistered
    Guest
    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.

  7. #7
    Disagreeably Disagreeable
    Join Date
    Aug 2001
    Posts
    711
    >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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. array initialization & C standard
    By jim mcnamara in forum C Programming
    Replies: 2
    Last Post: 09-12-2008, 04:25 PM
  2. Bug in iterator comparison in C++ standard?
    By steev in forum C++ Programming
    Replies: 14
    Last Post: 07-12-2008, 01:02 AM
  3. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 04:49 AM
  4. C/C++ standard
    By confuted in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 07-06-2003, 04:22 AM
  5. standard language, standard compiler?
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 09-03-2001, 05:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21