Two points to consider.
-
getchar_unlocked
is deprecated in Windows because it is thread unsafe version ofgetchar()
. -
Unless speed factor is too much necessary, try to avoid
getchar_unlocked
.
Now, as far as speed is concerned.
getchar_unlocked > getchar
because there is no input stream lock check in getchar_unlocked
which makes it unsafe.
getchar > scanf
because getchar
reads a single character of input which is char type whereas scanf can read most of the primitive types available in c.
scanf > cin (>> operator)
because check this link
So, finally
getchar_unlocked > getchar > scanf > cin