Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

what can i use instead of "cin" when getting input for "char" in c++?

+5 votes
asked Feb 17, 2025 by cpp guy (1,020 points)

2 Answers

+1 vote
answered Feb 17, 2025 by Ayush Srivastava (460 points)
selected Feb 28, 2025 by cpp guy
 
Best answer
char ch;
cin.get(ch);
cout << "enter " << ch << endl;
0 votes
answered Feb 18, 2025 by Peter Minarik (101,340 points)

What is wrong with std::cin?

If you want to use the C library, you can use that instead. Look at scanf().

E.g.:

#include <cstdio>

int main()
{
    char ch;
    std::scanf("%c", &ch);
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...