diff --git a/.readme.md.swp b/.readme.md.swp new file mode 100644 index 0000000..cc19c57 Binary files /dev/null and b/.readme.md.swp differ diff --git a/tris.c b/tris.c index da9eacf..69a6311 100755 --- a/tris.c +++ b/tris.c @@ -1,29 +1,30 @@ #include "tris.h" +#if os + /*Legge dalla tastiera senza usare il buffer*/ + int mgetchar(){ + char buf=0; + struct termios old={0}; + if(tcgetattr(0,&old)<0) + perror("tcsetattr()"); + old.c_lflag&=~ICANON; + old.c_lflag&=~ECHO; + old.c_cc[VMIN]=1; + old.c_cc[VTIME]=0; + if(tcsetattr(0,TCSANOW,&old)<0) + perror("tcsetattr ICANON"); + if(read(0,&buf,1)<0) + perror("read()"); + old.c_lflag|=ICANON; + old.c_lflag|=ECHO; + if(tcsetattr(0,TCSADRAIN,&old)<0) + perror("tcsetattr ~ICANON"); + return (buf); + } +#endif + /*Funzioni*/ -/*Legge dalla tastiera senza usare il buffer*/ - -UX int mgetchar(){ -UX char buf=0; -UX struct termios old={0}; -UX if(tcgetattr(0,&old)<0) -UX perror("tcsetattr()"); -UX old.c_lflag&=~ICANON; -UX old.c_lflag&=~ECHO; -UX old.c_cc[VMIN]=1; -UX old.c_cc[VTIME]=0; -UX if(tcsetattr(0,TCSANOW,&old)<0) -UX perror("tcsetattr ICANON"); -UX if(read(0,&buf,1)<0) -UX perror("read()"); -UX old.c_lflag|=ICANON; -UX old.c_lflag|=ECHO; -UX if(tcsetattr(0,TCSADRAIN,&old)<0) -UX perror("tcsetattr ~ICANON"); -UX return (buf); -UX} - /*Stampa la tabella del tris*/ void stampa(){ int i,k; @@ -48,10 +49,9 @@ void stampa(){ /*Cancella la tabella del tris*/ void vuota() { - for(i=0;imax){ max=t; mi=i; @@ -246,7 +250,6 @@ void medio(){ } } } - stampa(); tabella[mi][mk]=2; } diff --git a/tris.h b/tris.h index ec7337f..71876b4 100755 --- a/tris.h +++ b/tris.h @@ -31,7 +31,6 @@ #define os 0 #define clear "cls" #define sleep(x) Sleep(x) - #define UX // #else @@ -40,7 +39,6 @@ #define os 1 #define clear "clear" #define sleep(x) usleep(x*100) - #define UX int mgetchar(void); #endif