Can you press a key to transport you to some place in the prog ?

This is a discussion on Can you press a key to transport you to some place in the prog ? within the C++ Programming forums, part of the General Programming Boards category; Is there any way of making a prog go back to the start or back to some place by just ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    91

    Can you press a key to transport you to some place in the prog ?

    Is there any way of making a prog go back to the start or back to some place by just pressing a key once without having to type enter?



    i know yuo can say something like

    while(key=='y')
    {

    cout<<"do you want to go again y/n";
    cin>>key

    }

    but i want it so as soon as you type n the prog goes back to the beginning of the while loop.

  2. #2
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    sir, yes, sir...

    getch(var);

    I can't remember the header that it's in.

  3. #3
    Registered User Casey's Avatar
    Join Date
    Jun 2003
    Posts
    47
    <conio.h> for some compilers, the various curses libraries also have a getch function. But keep in mind that it's not a standard function, so you may not even have it.

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Some help here
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [HELP] key press
    By Dakaa in forum C Programming
    Replies: 6
    Last Post: 05-30-2009, 12:16 PM
  2. Need help: wait for key press
    By Pan in forum C++ Programming
    Replies: 4
    Last Post: 04-11-2006, 01:26 AM
  3. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 04:39 AM
  4. Replies: 1
    Last Post: 10-07-2001, 01:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21