Hey,

Is there any equivalent of conio.h for Linux???


I basically want getche to work in linux..
Is there any alternate??

Use ncurses perhaps ?

Or lots of messing about with termios ?

Or try not to write programs which are so tied to conio that they're not portable.

WHAT IS NCURSES??????


everybody suggest Ncurses..


What is it???

And how is it used?

Member Avatar for iamthwee

>WHAT IS NCURSES??????

What is google?

Mr CoolDude (i am thwee),

Please Post iff u can be of any help :)


..

And Is their any other soln (Apart form ofcourse THE NCURSES)

Member Avatar for iamthwee

Well I would just use ncurses, but you could possibly use below? Chances are you prolly don't need either unless you're making a crappy console game, or a password program.

#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>

void changemode ( int );
int  kbhit ( void );

int main ( void )
{
   int ch;
   changemode ( 1 );
   while ( !kbhit() )
   {
      putchar ( '.' );
   }

   ch = getchar();

   printf ( "\nGot %c\n", ch );

   changemode ( 0 );
   return 0;
}

void changemode ( int dir )
{
   static struct termios oldt, newt;

   if ( dir == 1 )
   {
      tcgetattr ( STDIN_FILENO, &oldt );
      newt = oldt;
      newt.c_lflag &= ~ ( ICANON | ECHO );
      tcsetattr ( STDIN_FILENO, TCSANOW, &newt );
   }
   else
      tcsetattr ( STDIN_FILENO, TCSANOW, &oldt );
}

int kbhit ( void )
{
   struct timeval tv;
   fd_set rdfs;

   tv.tv_sec = 0;
   tv.tv_usec = 0;

   FD_ZERO ( &rdfs );
   FD_SET ( STDIN_FILENO, &rdfs );

   select ( STDIN_FILENO + 1, &rdfs, NULL, NULL, &tv );
   return FD_ISSET ( STDIN_FILENO, &rdfs );

}

> WHAT IS NCURSES??????
> everybody suggest Ncurses..
> What is it???
> And how is it used?
Do you want your diaper changing as well?

WTF do you think the links in my post were all about - how to make cheese on toast using small theatre nuclear devices?

If you knew the reply was going to be ncurses, then why did you
a) bother to ask in the first place
b) not bother to do even a small amount of research for yourself.

If neither of these things crossed your mind, then forget about becoming a programmer.

> WHAT IS NCURSES??????
> everybody suggest Ncurses..
> What is it???
> And how is it used?
Do you want your diaper changing as well?

WTF do you think the links in my post were all about - how to make cheese on toast using small theatre nuclear devices?

If you knew the reply was going to be ncurses, then why did you
a) bother to ask in the first place
b) not bother to do even a small amount of research for yourself.

If neither of these things crossed your mind, then forget about becoming a programmer.

If u can be of help then it OK otherwise stop [EMAIL="F@#king"]F@#king[/EMAIL] replying to mu thread...

commented: read the posts before you start insulting people +0

If u can be of help then it OK otherwise stop F@#king replying to mu thread...

Mr CoolDude (i am thwee),

Please Post iff u can be of any help :)

ajaxjinx, please don't take it personal. I am quite sure that Iamthwee nor Salem were trying to offend you at all. They are good guys that will help you, if you don't take it personal.

Sometimes we say the first things that come to our minds thinking not much of it, and without thinking how the recipient of our comments are going to take it.

But you are welcome here, and no one is trying to offend you.

Be happy!.

>If u can be of help then it OK otherwise stop F@#king replying to mu thread...
ajaxjinx, you're being very foolish by saying such a thing. You never deserve an answer, you earn it by showing that you are willing to work to find the answer, and that means researching when someone gives a recommendation, reading the links that they give you, etc.. By giving rude remarks by demanding help from people who could potentially help you, you waste their time, and you risk losing valuable help.

By the way, read this. Typing 2 extra keystrokes to say "you" instead of a certain instant messaging abbreviation is actually quite a good idea.
http://www.catb.org/~esr/faqs/smart-questions.html#writewell

Seems like I have been misunderstood here... Apologies for that..

I am really not trying to offend anyone, but being a newbie to this forum, the kind of know-it-all attitude, on part of some members is a BIG turn off.


But ya..

Thanks anyways.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.