LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-10-2004, 04:57 PM   #1
darkarcon2015
Member
 
Registered: Jun 2004
Location: Potsdam, NY
Distribution: Fedora Core 6
Posts: 201

Rep: Reputation: 30
Help with getch...


Helllo, I was wondering how I can get my program to do something around these lines: I want it so that when a certain key is pressed, something happens. Like "Press Enter to Start." Can someone show me a line or a snipet of code that could help me? Thanks.
 
Old 09-10-2004, 08:52 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint
Posts: 9,707

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
You'll find a 13 years old implementation of getch that should still work for current linux at http://ndirty.cute.fi/~karttu/shoginew/getch.c
 
Old 09-11-2004, 01:37 PM   #3
darkarcon2015
Member
 
Registered: Jun 2004
Location: Potsdam, NY
Distribution: Fedora Core 6
Posts: 201

Original Poster
Rep: Reputation: 30
Will this work in Windows? Because I don't think I have the "sgtty.h" header file.
 
Old 09-12-2004, 05:37 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint
Posts: 9,707

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
You didn't specify you wanted a Windows answer ...
In that case, I think getch is a standard (dos) call, so sth like:

printf("Press Return to continue");
while(getch()!='\n') ;

should work.
 
Old 09-12-2004, 08:48 AM   #5
N43
LQ Newbie
 
Registered: Sep 2004
Location: Germany
Distribution: Slackware
Posts: 13

Rep: Reputation: 0
You need the conio.h header file to use getch() under Windows. Possibly getch!='\n' won't work bacause it doesn't represent the return key. If it doesn't work try out getch!=char(13)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Where is getch()....... rajsun Programming 2 03-28-2005 11:40 AM
getch() in FC2 natm Programming 3 10-20-2004 02:26 PM
how to get getch() working with c++ cool_ashwin22 Programming 3 08-03-2004 10:58 AM
getche() and getch() kamransoomro84 Programming 2 05-09-2004 12:36 PM
ncurses getch() deveraux83 Programming 3 08-06-2003 07:27 AM

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

All times are GMT -5. The time now is 04:51 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration