Re: Output without stdio.h or iostream

Discussion in 'C Programming' started by Lew Pitcher, Jul 3, 2003.

  1. Lew Pitcher

    Lew Pitcher Guest

    On 3 Jul 2003 07:52:30 -0700, (Gabriel Flemming)
    wrote:

    >i heard it wouldn't be possible to build a function that sends output
    >(maybe a text string) to the console without using the C/C++
    >standard-functions from the standard library (puts,printf or
    >whatever)...
    >
    >is this correct?


    Yes. But, as it is implementation dependant, it isn't discussed here.

    >or is there any possibility of writing such a function WITHOUT the
    >usage of any function from the standard library?


    Yes again.

    >to me, it doesn't make sense, that it could be impossible to do this,
    >because every of the standard functions has to be implemented in the
    >compiler


    Nonsense. The standard functions have to accompany the compiler; the compiler
    doesn't have to implement them in the same manner that it implements a switch()
    or if() statement. I/O functions are /not necessarily/ intrinsic to the compiler
    (unlike COBOL or Fortran, where the I/O facilities are parsable language
    elements, and not callable functions).

    > (AND THEREFORE THERE HAS TO EXIST THE NEEDED CODE, HASN'T
    >IT???).


    write(int, const void *, size_t);

    void my_output_routine(char *string)
    {
    size_t length;

    for (length = 0; *(string+length); ++length);
    write(1,string,length);
    }

    writes the given string to stdout (in Unix or Linux, given a unix compatable
    runtime library).

    --
    Lew Pitcher
    IT Consultant, Enterprise Technology Solutions
    Toronto Dominion Bank Financial Group

    (Opinions expressed are my own, not my employers')
     
    Lew Pitcher, Jul 3, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vicent

    iostream or stdio

    Vicent, Aug 25, 2003, in forum: C++
    Replies:
    2
    Views:
    1,743
  2. Joona I Palaste

    Re: Output without stdio.h or iostream

    Joona I Palaste, Jul 3, 2003, in forum: C Programming
    Replies:
    0
    Views:
    721
    Joona I Palaste
    Jul 3, 2003
  3. Malcolm

    Re: Output without stdio.h or iostream

    Malcolm, Jul 3, 2003, in forum: C Programming
    Replies:
    0
    Views:
    1,060
    Malcolm
    Jul 3, 2003
  4. Dan Pop

    Re: Output without stdio.h or iostream

    Dan Pop, Jul 4, 2003, in forum: C Programming
    Replies:
    0
    Views:
    378
    Dan Pop
    Jul 4, 2003
  5. Replies:
    18
    Views:
    1,922
    crazzybugger
    Oct 22, 2006
Loading...

Share This Page