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.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
How to stop program crashing
+1
vote
asked
Mar 10, 2019
by
Kyle
(
200
points)
Every time I enter a character for my switch statement it just crashes is there anyway to stop this
urgent
c
switch
very-urgent
please-help
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
1 Answer
0
votes
answered
Mar 12, 2019
by
201851116 SHAH JAINILKUMAR VIPULBHAI
(
540
points)
selected
Mar 12, 2019
by
Kyle
Best answer
please use fflush(stdin); whenever you are inserting the string, You have to use fflush because if you are entering the enter so at that time switch statement takes the '\n' as a character input, and that's why your program had been crashed.....
commented
Mar 13, 2019
by
IamAkashGhosh
(
140
points)
If it is C language you need to write "fflush(stdin);" after reading the character to clear the buffer. But it may be happening for some other reason to. So the code is important to analyze.
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...