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.
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 .
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.