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]


wicked :D… had an enjoyable moment reading this code… cool

1 Like

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; }


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

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

1 Like

GOD code !!

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


a b

and MY CODE is

char 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?

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

@mukel I am implementing this code but I am getting An error that i am not able to understand. Can you help? Ke9Y42 - Online C++ Compiler & Debugging Tool - here is the link

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

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

Fast i/o