Which command reads one character even if that character is a blank space? :?:

try

#include <cstdio>

int ca;
ca = fgetc(stdin);

fgetc is a C function. The C++ way to do it is

char ch = std::cin.get()

If the user enters the single character I don't see a reason why you can't use:

char c;
c = getchar();

But it all depends on the requirement of the software.

gets() also does the same, but its said to be a dangerous function causing buffer over flow...

Just included so that you are aware of it..... Don't use gets()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.