getchar_unlocked() in C


The function getchar_unlocked() is deprecated in Windows because it is a thread unsafe version of getchar(). It is suggested not to use getchar_unlocked(). There is no stream lock check that’s why getchar_unlocked is unsafe. The function getchar_unlocked() is faster than getchar().

Here is the syntax of getchar_unlocked() in C language,

int getchar_unlocked(void);

A program of getchar_unlocked() in C is as follows −

Example

 Live Demo

#include <stdio.h>

int main() {
   char val;
   val = getchar_unlocked();
   printf("Enter the character : \n");
   printf("Entered character : %c", val);
   return 0;
}

Output

Here is the output

Enter the character : a
Entered character : a

Updated on: 25-Jun-2020

264 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements