Here is my code:
#include
void scan(int* i)
{
int t=0;
char c;
bool negative=false;
c=getchar_unlocked();
while(c<\'0
Windows have the equivalent, _getchar_nolock, it is Windows specific.
See this link:
https://msdn.microsoft.com/en-us/library/4y2e9z0c.aspx
So if you are happy with a non-threadsafe version and you want the best possible performance you could do something like this:
#ifdef WIN32
// no getchar_unlocked on Windows so call _getchar_nolock
inline int getchar_unlocked() { return _getchar_nolock(); }
#endif