Electronics Lab Philippines

nonterminating program...

Offline n

  • ***
  • 91
  • 4
  • Gender: Male
  • prioritize your priorities!
nonterminating program...
« on: February 28, 2008, 12:36:46 PM »
 i want to create a turbo c program that would only terminate (go back to its source code) when i entered a certain letter/number.... how do i make it sir? please help...
example:
in the running program:
menu
(a) i love you
(b) i hate you
(c) exit




kapag ni run ko na po iyong program (ctrl+F9) yan po iyong makikita ko sa screen tapos kapag pinindot ko iyong "a" ipiprint niya eh "i love you" tapos babalik ulit dun sa may menu at pag pinindot ko ulit iyong "a" print ulit "i love you" balik sa menu, pindot "b" print "i hate you" tapos pag pindot "c" balik na ako sa edit window... gets niyo naman po di ba?

please help me... thanks po.. :) :) :)
basa basa basa

Offline zer0w1ng

  • *****
  • 2190
  • 308
  • Gender: Male
  • Enter any 11-digit prime number to continue...
    • The Cebuano Geek
Re: nonterminating program...
« Reply #1 on: February 28, 2008, 01:52:22 PM »
Put a getch() before the end.
This will pause your program before quitting and waits for a key to be pressed.
The Cebuano Geek

Offline simplywel

  • **
  • 38
  • 3
  • Gender: Male
Re: nonterminating program...
« Reply #2 on: February 28, 2008, 01:57:29 PM »
mas madali kapag gumawa ka muna ng flow chart
then write mo na yung codes..
People are just people, it's what they do which makes them good or bad

Offline kamote

  • ****
  • 126
  • 4
Re: nonterminating program...
« Reply #3 on: February 28, 2008, 02:55:00 PM »
ALT F5 para makita mo yung display screen :P
pero mas maganda ang getche();

Offline 0b00000111

  • *****
  • 6201
  • 405
  • There is no delight in owning anything unshared.
Re: nonterminating program...
« Reply #4 on: February 28, 2008, 05:15:25 PM »
i want to create a turbo c program that would only terminate (go back to its source code) when i entered a certain letter/number.... how do i make it sir? please help...
example:
in the running program:
menu
(a) i love you
(b) i hate you
(c) exit







kapag ni run ko na po iyong program (ctrl+F9) yan po iyong makikita ko sa screen tapos kapag pinindot ko iyong "a" ipiprint niya eh "i love you" tapos babalik ulit dun sa may menu at pag pinindot ko ulit iyong "a" print ulit "i love you" balik sa menu, pindot "b" print "i hate you" tapos pag pindot "c" balik na ako sa edit window... gets niyo naman po di ba?

please help me... thanks po.. :) :) :)

try this
Code: [Select]

int main()
{
char x;


do
  {
  // dito mo ipasok ang code mo
   
  x=getch();
  }while(x!='0'); // habang di mo pinipindot ang 0, di ka pa rin mag eexit

return 0;

}
E-Gizmo Mechatronix Central: www.e-gizmo.com

Tel #: (63)(2) 536-3378
Globe +63915-973-7691
Smart +63921-779-0748

Location Map

YM: julie.egizmo  aka Born2BeWired  ;D

Offline n

  • ***
  • 91
  • 4
  • Gender: Male
  • prioritize your priorities!
Re: nonterminating program...
« Reply #5 on: February 29, 2008, 12:52:41 PM »
try this
Code: [Select]

int main()
{
char x;


do
  {
  // dito mo ipasok ang code mo
   
  x=getch();
  }while(x!='0'); // habang di mo pinipindot ang 0, di ka pa rin mag eexit

return 0;

}

thanks po sir sevenstring... ang galing mo talaga... hehehe... ayos na.... hehehe!!!! ;D ;D ;D ;D
basa basa basa