From 8b143e783111a0b61b45ce0feec3c84108eef055 Mon Sep 17 00:00:00 2001 From: Rnhmjoj Date: Thu, 29 Nov 2012 00:28:00 +0100 Subject: [PATCH] Modifiche minori MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *Usato un metodo piĆ¹ sicuro per includere la funzione int mgetchar(). *Tentativo di bugfix non riuscito. --- .readme.md.swp | Bin 0 -> 12288 bytes tris.c | 65 ++++++++++++++++++++++++++----------------------- tris.h | 2 -- 3 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 .readme.md.swp diff --git a/.readme.md.swp b/.readme.md.swp new file mode 100644 index 0000000000000000000000000000000000000000..cc19c57a57b2cd91561ebfd547a7966ebc6fedad GIT binary patch literal 12288 zcmeI2zmFS56vyX~C0MLhMsH(MI#gzh1Pj%3eji<^009Qkf@Me7c;_|G<^0 z(Kd$u4#ob*oIp9LSD8R2a25h7j(bu1pNqo z16_rFc~OW%=mzu}^z(TkYUq9FJ*Wr$`GOEXKzE_9pi}50=tF1#or9i*9y~9^m(Ul` zDfBsX721V3t^O0^ZT;ZzMSA5q9R$krX{0nQ}-FirZ`EX0xtWi za<^4q*+3{wfp}Myji}l*|6al|*4(-_+{J{hIz6@MjYw8;C?U06rA{g%D^Do8ZgMgF zWY|?WiV}vw;SSfE8;ji_Nxb=!6LyZ`<2qin8C-%j{GlZ+1_IV6$LON=fTTKyO^aGZ zW1yn>dd6K1SM#S+L z#rC$+2#+fXpV5Wgof#x-oKu%9{K6^X4vhI7NobxL&wx?|^e#wD$(9-(M+ybx=lA58 z{YT)#>U&x?Se*B7y7Z##{Ic(ZP8F)MgCs8*U^T|Uy2O^>M7iMPI(Dj1r^pXKt;|Jb zYV15V=y$TzsN3>Vqbs1}7{_C@IZO-QG7zKNvF*}z#qSpFf~YuEasy%EkwtNSZvdhj ziv~f(a-9ZLHxTngJjgm%s5Fjz*&KH4d;|D+7UJjiKQFO^c3Z5-C+eBmwh-?=dWqFg Jci0{i{sNx2LD&EQ literal 0 HcmV?d00001 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