Thread: Simple "Do you want to continue"

  1. #1
    Unregistered
    Guest

    Simple "Do you want to continue"

    What's the best way to do a "Do you want to continue"?

    I tried the "Do you want to continue? y/n", every time an error comes up with something to do with the characters.

    Please help

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    There are some tips on how to pause a program in the board FAQ, if nothing there suggests a solution to your, (somewhat cryptic), problem, post your code.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User breed's Avatar
    Join Date
    Oct 2001
    Posts
    91
    There are two functions you could use that are under the
    #<ctype.h> & <conio.h> header files

    main90
    {
    char ch;

    printf("\n Do you want to continue >");
    ch = getch(ch);
    ch=toupper(ch);

    if(ch == 'Y')
    {
    /*do some coding*/
    }
    else
    exti(1); /*this is in the stdlib.h*/
    Before you judge a man, walk a mile in his
    shoes. After that, who cares.. He's a mile away and you've got
    his shoes.
    ************William Connoly

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    reply

    Code:
    
    char Key='y';
    while(Key=='y')
    {
    
      ...
    
      printf("Do you want to continue? y/n);
      scanf(&Key); //Not sure about the exact syntax :)
    }
    
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    reply

    I know, scanf() is a little bit rusty for me . I see that I forgot a " too, but I'm pretty sure that the general structure works...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    12
    Code:
            WORKING-STORAGE SECTION.
            77  DO-YOU-WANT-TO-CONTINUE    PIC X VALUE "Y".

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Always interesting to see other languages, (even COBOL), but hardly applicable to the C board.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating very simple text editor using c
    By if13121 in forum C Programming
    Replies: 9
    Last Post: 10-19-2010, 05:26 PM
  2. Simple message encryption
    By Vicious in forum C++ Programming
    Replies: 10
    Last Post: 11-07-2004, 11:48 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Simple simple program
    By Ryback in forum C++ Programming
    Replies: 10
    Last Post: 09-09-2004, 05:48 AM
  5. Need help with simple DAQ program
    By canada-paul in forum C++ Programming
    Replies: 12
    Last Post: 03-15-2002, 08:52 AM