473,320 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

alternative for getch( ) in linux

Can anyone tel me the alternative for getch( ) in linux i.e the code so that the output should remain on the screen until the user presses enter.........
Oct 24 '07 #1
3 11314
Can anyone tel me the alternative for getch( ) in linux i.e the code so that the output should remain on the screen until the user presses enter.........

You can use

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  
  3. char getchlin(void); /* Prototype */
  4.  
  5. int main(void)
  6. {
  7. char t;
  8. t=getchlin(); /*invoke getchlin in Linux instead of getch in windows*/
  9. return 0;
  10.  
  11. return 0;
  12. }
  13.  
  14. char getchlin()  /*definition */
  15. {
  16. char c;/*return value*/
  17. char test; /*to retain the screen*/
  18.  
  19. scanf("%c",&c);
  20. scanf("%c",&test);
  21. return (c);
  22. }
  23.  
Hope the above code segment gives you the soulution.

Cheers
Chandra
Oct 25 '07 #2
Thank you very much chandra.
Oct 26 '07 #3
ashitpro
542 Expert 512MB
You can use

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  
  3. char getchlin(void); /* Prototype */
  4.  
  5. int main(void)
  6. {
  7. char t;
  8. t=getchlin(); /*invoke getchlin in Linux instead of getch in windows*/
  9. return 0;
  10.  
  11. return 0;
  12. }
  13.  
  14. char getchlin()  /*definition */
  15. {
  16. char c;/*return value*/
  17. char test; /*to retain the screen*/
  18.  
  19. scanf("%c",&c);
  20. scanf("%c",&test);
  21. return (c);
  22. }
  23.  
Hope the above code segment gives you the soulution.

Cheers
Chandra



If you notice the working "getch".
Then you will come to know that it doesn't echo the character on console.
But with above code I can see the character on screen.
This is something like "getchar".

reply if I am wrong.
Oct 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

383
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
3
by: GLCODER | last post by:
Does anyone know of a getch() equivalent that exists in linux? I have just started doing some basic programming and am currently running Knoppix on CD. So I'm not sure what kind of file library I...
5
by: freakykanwar | last post by:
how do we pause screen on LINUX, till user presses any key.. like we use getch() in WINDOWS & getchar() in UNIX..
5
by: Sankar | last post by:
Dear all, In my programming snippet compiled in Linux 2.6, I have a getch() , but the program when executed does not wait for my input.. fflush(stdin), fflush(stdout) - All these did not help. ...
3
by: peter | last post by:
I've been wrestling on and off with this problem for over a year now, without success. Basically, I am looking for a simple set of screen and keyboard manipulation commands that will run...
4
by: jpenguin | last post by:
I am taking a college class for C++, they use Windows, at home I use linux. So for compatibility, can I use curse.h to perform like conio and getch()
1
by: ChuckB | last post by:
Ok, I'm trying to create a GTK+ application that scrolls Hs across the screen until you press q or Q. I've got it working in console wise using ncurses. What I'm trying to do now is make a full...
7
by: Steven Woody | last post by:
Hi, I am in Linux writing a program using setlocale(3). But I found, only the first invocation of setlocale(3) can be success, any subsequent calling of this function will fail $B!J(B return...
16
by: fuzhen | last post by:
If I want to "press any key to continue" in Windows, I can use getch() But the getch() isn't a standard C function So what should I to do in Linux?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.