HI, I am looking for faster input and output method for the C other than just normal scanf and printf modules.

Please elaborate by simple example.

thanks :)

This is highly system dependent and it is unlikely, even if we knew your system, that a 'simple example' would present itself without a significant amount of work.
I'd suggest you google for I/O optimization for your particular platform.

Please elaborate by simple example.

No, you elaborate first. What kind of I/O? Are you doing type conversions like scanf and printf? Do you know about the unformatted I/O functions? Have you profiled your code and confirmed that C's standard I/O is too slow?

I was meaning to know the buffer I/O method and yeah i have some knowledge of unformatted
methods like gets and puts .

And i havent confirmed but got to know from some sites that standard I/O methods are slower than buffer I/O methods(and method wasn't explained on those sites) as faster I/O methods are required for some competitions where run time allowed is 2-3 sec for 10^6 integer inputs .

I was meaning to know the buffer I/O method

Can you specify what you mean by "buffer I/O method"? The standard I/O streams are buffered by default for performance. You can adjust the buffering amount to suit your needs, or even turn it off. Presumably the sites you were reading were talking about using system functions instead of standard C functions, such as POSIX's read() or Windows' ReadFile(). These can potentially be faster, or not, depending on many factors and require thorough testing.

I would guess he means "formatted I/O" instead of buffered I/O. Which would be fprintf/fscanf.
Basically the functions that try to interpret the data that's read to some specific type.
I never tried in C/C++ but in Java it was quite clear that ObjectInputStream.readInt() is much slower than FileInputStream.read().
If I'm wrong Narue's post gives teh correct answer.

In DaniWeb terms the undefined behaviour could be translated: risk getting struck by lightning by Goddess Narue ;) if you use it.

I never tried in C/C++ but in Java it was quite clear that ObjectInputStream.readInt() is much slower than FileInputStream.read().

It's also generally a safe assumption that reading a string and converting it to another type is slower than simply reading and storing a string.

This article has been dead for over six months. Start a new discussion instead.