Cool fast IO implementation!!!

Any hints or improvements are welcome.

This is a cin/cout (very) fast replacement. This redefines cin/cout so, just include this code to boost I/O speed, and everything should work like cin/cout.
Output only works fast when ONLINE_JUDGE is defined, else it flushes constantly, which is desirable when code is tested locally.

Voila le code: [Fast IO][1]
[1]: http://ideone.com/fOK6CW

11 Likes

Pity the Markdown vandalizes the _'s used in the code :frowning: I guess people would just have to copy-paste from the ā€œeditā€ option.

FIXED: Link to code is provided.

1 Like

wicked :Dā€¦ had an enjoyable moment reading this codeā€¦ cool

1 Like

@mukel I am implementing this code but I am getting An error that i am not able to understand. Can you help? http://ideone.com/Ke9Y42 here is the link

Fixed #includes issue and link updated. Any feedback, extension or even some shrinked version is apreciated, enjoy

Very cool!!!

A small suggestion:

It shall be better to change the following line:

inline IO& operator << (char * s) { while (*s) putChar(*s++); return *this; }

into:

inline IO& operator << (const char * s) { while (*s) putChar(*s++); return *this; }

Otherwise there can be compiler warnings when output constant strings like: cout << " ";

Done, + added very basic usage example, enjoy!!!

Fixed bug with sign, + little improvement reading signed integers. Tested on SPOJ INTEST problem.

Can you please help me, Iā€™m trying to compile your code on Windows, Iā€™m using Code::Blocks(gnu gcc compiler) and Iā€™m getting next warnings: ā€˜getc_unlockedā€™ was not declared in this scope , ā€˜putc_unlockedā€™ was not declared in this scope

GOD code !!

Not sure if it is a bug. But when I have 2 space-separated characters in stdin like,

STDIN

a b

and MY CODE is

char x,y;

cin>>x>>y;

x stores ā€˜aā€™ and y stores ā€™ ā€™ where it should avoid spaces and store ā€˜bā€™ (since it emulates cin).

Otherwise, itā€™s a charm :slight_smile:

this does not work on codeforces , why is it so?

this does not work on codeforces , why is it so?