ฟังก์ชัน getchar_unlocked() เลิกใช้แล้วใน Windows เนื่องจากเป็นรุ่นเธรดที่ไม่ปลอดภัยของ getchar() ขอแนะนำว่าอย่าใช้ getchar_unlocked() ไม่มีการตรวจสอบการล็อกสตรีม นั่นเป็นสาเหตุที่ getchar_unlocked ไม่ปลอดภัย ฟังก์ชัน getchar_unlocked() เร็วกว่า getchar()
นี่คือไวยากรณ์ของ getchar_unlocked() ในภาษา C
int getchar_unlocked(void);
โปรแกรมของ getchar_unlocked() ใน C มีดังต่อไปนี้ -
ตัวอย่าง
#include <stdio.h>
int main() {
char val;
val = getchar_unlocked();
printf("Enter the character : \n");
printf("Entered character : %c", val);
return 0;
} ผลลัพธ์
นี่คือผลลัพธ์
Enter the character : a Entered character : a