Implementation of those I/O functions in C

1
2
3
int scanf ( const char * format, ... );
int printf ( const char * format, ... );
// and also sscanf, ssprintf, fscanf, fprintf, etc. 

How to implement these? Special statement? Or API?
Last edited on
And also iostreams. Thanks.
¿Que?
Implementation of those I/O functions in C

Read the implementation's source for the functions. Trying to redefine language features is going to lead to disaster.
ok.
Is there anything particular about their implementation that you find confusing?
reinventing the wheel is valid if you need special functionality not exposed by standard equivalents, if you need (and are able) to gain performance, or for some reason you can't use standard library (ex. it's not available)

In all other cases it's a waste of time and subject to laughing.
are you asking how to use variable length arg lists in a function?
that is really the only thing special about those (well, that and the 'how' behind writing to the 'console?' or reading from the 'keyboard' which is system specific).

Honestly if you re-created those its probably best done in local assembly language.

converting numbers to text and text to numbers is very slow and a rewrite would give you a lot of lift if you have a specific format in mind rather than a universal approach. I would not, in that case, attempt to rewrite the existing ones but just make a new wrapper that uses the existing inside.

In any case, maybe you could say what the goal is?
Last edited on
Topic archived. No new replies allowed.