LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-07-2014, 12:13 PM   #1
user355
LQ Newbie
 
Registered: Oct 2014
Posts: 3

Rep: Reputation: Disabled
Unhappy how to non break out from this program when c) is pressed ?


#include <stdio.h>
int main(void) {
char choice;
printf("Who invented telephone :\n");
printf("a) Alexander Bell ?\n");
printf("b) Denzel Uashington ?\n");
printf("c) Help !\n");
scanf("%c", &choice);
switch (choice)
{
case'a':
printf("Right answer.\n");
break;
case 'b':
{
printf("Wrong answer.\n");
break;
case 'c':
printf("I think is case a.\n");
break;
}
default:
printf("Wrong button.\n");
break;
}
getchar();

return 0;
}
 
Old 10-07-2014, 12:31 PM   #2
mina86
Member
 
Registered: Aug 2008
Distribution: Debian
Posts: 517

Rep: Reputation: 229Reputation: 229Reputation: 229
Use code tags.

You need a loop or a goto.
 
1 members found this post helpful.
Old 10-07-2014, 02:18 PM   #3
user355
LQ Newbie
 
Registered: Oct 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
what kind a loop ! a do while loop !
 
Old 10-07-2014, 03:12 PM   #4
mina86
Member
 
Registered: Aug 2008
Distribution: Debian
Posts: 517

Rep: Reputation: 229Reputation: 229Reputation: 229
do-while will work, yes.
 
Old 10-07-2014, 04:19 PM   #5
user355
LQ Newbie
 
Registered: Oct 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
can <dos.h> function work in codeblocksmingw or c4droid ?

Last edited by user355; 10-08-2014 at 03:17 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Netbeans 7.3: Program does not break at break points when debugging JavaScript OtagoHarbour Programming 0 02-22-2013 02:44 AM
Map a keypress to a GUI button (when keycode 175 pressed a GUI button pressed) wikapuki Linux - Desktop 0 09-16-2010 09:08 AM
break while [...] loop when a program finishes throughthegreens Linux - Newbie 6 02-18-2010 11:12 AM
Break the order of calling functions in a program horacioemilio Programming 7 12-23-2007 10:40 AM
My basic encrypt/uncrypt program... break; breaks when not supposed 2 in java Laptop2250 Programming 8 01-20-2004 09:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration