I have recently started learning I/O file operations in C. And in this code I am facing an issue the while loop is not exiting even when I put nonwhite space character ' ' . Plz, tell me where I am wrong and how to exit while loop.
#include <stdio.h>
int main()
{
char a = 0;
while ((a = (char)getchar()) != ' ');
ungetc(a, stdin);
printf("\n Value of A is %c", a);
return 0;
}