473,385 Members | 1,356 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,385 software developers and data experts.

i cannot use getch() function in linux , but i need to ask the user to press enter

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. void func(int);
  4. void main()
  5. {
  6. int x=1;
  7. func(x);
  8. printf("##############");
  9. }
  10. void func(int x)
  11. {
  12.     if(x!=0)
  13.     {
  14.     printf(" X!=0");
  15.     getch();
  16.     return;
  17.     }
  18. }
on compiling this code the error is

e2.c:2:18: error: conio.h: No such file or directory


and on commenting <conio.h> the error is ax follows

e2.c:2:18: error: conio.h: No such file or directory


wat 2 do ????
Dec 6 '10 #1
3 3013
Banfa
9,065 Expert Mod 8TB
Don't use getch() to make your program pause at the end, it is unnecessary would be the best idea.

While you are about it main returns int not void. This might not have been a problem on Windows since MSVC supports main returning void as an extension but on Linux I imagine most of the compilers (gcc for instance) are more strict and you should return int to void undefined behaviour.

If you are going to write software for multiple platforms then get used to writing portable software and that means not relying on non-standard headers and libraries such as "conio.h".
Dec 6 '10 #2
SAP88
3
#include <curses.h> instead of <conio.h>
Dec 8 '10 #3
Raj K
9
Expand|Select|Wrap|Line Numbers
  1. #include <ncurses.h>
  2. int main()
  3. {
  4.   initscr();
  5.   cbreak();
  6.   printw("Press Any Key.. ");
  7.   getch();
  8.   endwin();
  9.   return 0;
  10. }
  11.  
- Make sure you have installed ncurses library before compiling.
- While compiling, pass a argument -lncurses to gcc



-RajX
Dec 9 '10 #4

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

Similar topics

4
by: penny336 | last post by:
hi here is my original// it can convert to upper case or lower case but require user press "enter" how to implement a without "press enter" version e.g. if input 'a' --> at commad prompt will show...
11
by: Pelo GANDO | last post by:
Hi everybody, It's me again...Pelo, for an other beginner question... What the code should be in C++ to wait for a keyboard entry in order to execute the sequal of my program...
5
by: junk mail | last post by:
My friend is trying to code a small c program where he wants to force the user to press enter and only enter to continue. Currently he is using getchar() with a loop but you can type any number...
13
by: Jesse Engle | last post by:
how can i allow a user of my program to enter paragraphs seperated by line spaces using gets() or a similar function? i want the user to be able to enter as many lines as they want, while able...
3
by: w. jORDAN | last post by:
Hello all, It's known to how to make user press enter in an asp:textbox and the form is submited by adding an attribute to the textbox with an onkeydown jscript eventhandler. For example,...
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
3
by: shaheda begum | last post by:
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.........
12
by: Daniel Klein | last post by:
I'm pretty new at php and web stuff so please be gentle with me. I'm trying to get a form to submit when the user presses the Enter key. I do not want to use javascript. I've googled this to...
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
2
by: arpitwcc | last post by:
i am making u user login page where there are few buttons at the top of the page like Home, Services, About Us etc and below it i hav Username -- textbox Password --textbox Login --image...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.