/*solution provided by kermi3 from this web posting http://cboard.cprogramming.com/archive/index.php/t-27714.html*/

#include <termios.h>
#include <unistd.h>

int mygetch(void)
{
struct termios oldt,
newt;
int ch;
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
return ch;
}
/*this point down was coded by Brandon Camadine*/
void mygetchs(int length,char array[],int display)
{
   int x;
   array[length-1]='\0';
   while(array[x]!='\0')
   {
array[x]=mygetch();
       if(display !=0)
       {
putchar(array[x]); } x++; } }
/*solution provided by kermi3 from this web posting 
http://cboard.cprogramming.com/archive/index.php/t-27714.html*/

#include <termios.h>
#include <unistd.h>

int mygetch(void)
{
struct termios oldt,
newt;
int ch;
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
return ch;
}
/*this point down was coded by Brandon Camadine*/
void mygetchs(int length,char array[],int display)
{
        int x; 
        array[length-1]='\0';
        while(array[x]!='\0')
        {
                
                array[x]=mygetch();
                if(display !=0)
                {
                        putchar(array[x]);      
                }       
                x++;    
        }
        
}

Reply via email to