本文介绍了C语言缺少键盘输入功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 认真思考库函数很重要 i认为对于tame(domare)输入流是有用的 函数就像这些我用的。 i不知道他们是对的 注意:当询问输入时:需要一个范围来验证 (最后整数,浮动和双重) ; int cf(void); _cf: mov eax,0 adc eax,0 ret / * int __stdcall getl_m(void * buf,int sz,FILE_m * file); / * legge da" file" una linea di al massimo sz-1 chars / *(oveszèlasize di buf) / * e la mette nel buffer buf la termina con'' \\ 0'' / * se errori di parametro ritorna 0 CF = 0 / * se i caratteri della linea / * eccedono i sz-1 chars ritorna - (lunghezza / * della stringa)e continua a leggere dal file fino a che trova''\ n'' / * altrimenti ritorna la lunghezza della stringa / * se incontra EOF CF = 1 altrimenti CF = 0 / * s = 0k,4k,8j,12r,16c,20b,24ra, 28P_buf,32P_siz,36P_file getl_m: push ebx push ecx push edx push edi push ebp push ebp %定义@buf [esp + 28] %define @sz [esp + 32] %定义@file [esp + 36] mov ebx,@ file mov ebp, @sz mov edi,@ buf xor eax,eax cmp ebp,0 jle .c0 mov [esp],ebx cmp edi,0 je .c0 cmp ebp,1 je .c4 mov byte [edi],0; / k = 2; --k = 1 cmp ebx,0 je .c0 jmp short .c3 .. c0: clc jmp .c7 ..c2: mov eax,edi mov byte [edi],0 sub eax,@ build stc jmp .c7 ..b0: inc edi ..c3: dec dword [ebx] jl .a0 mov edx,[ebx + 4] mov al,[edx] inc edx mov [ebx + 4],edx jmp short .a1 ..a0: call __fillbuf_m cmp eax,-1 je .c2 ..a1: mov [edi],al dec ebp jz .c4 cmp al,10 jne .b0 inc edi mov eax,edi mov byte [edi],0 sub eax,@ build clc jmp短.c7 ..c4: mov byte [edi],0 ..c5: dec dword [ebx] jl .a2 mov edx,[ebx + 4] mov al,[edx] inc edx mov [ebx +4],edx jmp短.a3 ..a2: 调用__fillbuf_m cmp eax, -1 je .c6 ..a3:; / arriva fino a''\ n'' cmp al,10 jne .c5 mov eax,@ build; / risposta negativa sub eax,edi clc jmp短.c7 ..c6: mov eax,@ buf sub eax, edi stc ..c7: %undef @buf %undef @sz %undef @file pop ebp pop ebp pop edi pop edx pop ecx pop ebx ret 12 / * int cf(void); _cf:a = 0;一个++ = 0;返回 getl_m: < b,c,r,j,k,k << @ buf = [s + 28],@ sz = [s + 32],@ file = [s + 36] b = @ file; K = @ SZ; J = @ BUF; a ^ = a; k< = 0?#。c0; * S = B; Ĵ== 0#.c0; k == 1#.c4; B * j = 0; b == 0#.c0; #≥C3; // k = 2; --k = 1 ..c0:clc; ##。c7; ..c2:a = j; B * J = 0;一个 - = @ BUF; STC; ##。c7; ..b0:{++ j; ..c3: - D [b]; !>?=#A0 | R = [B + 4]; AL = * R; ++ R; [b + 4] = r;#。a1; ..a0:__ fillbuf_m(); a == - 1#.c2; ..a1:* j = al; --k#C4!。 al!= 10#.b0; } ++ j;一个= j的; B * J = 0;一个 - = @ BUF; CLC; #.c7; ..c4:B * j = 0; ..c5:{ - D [b]; !>?=#A2 | R = [B + 4]; AL = * R; ++ R; [b + 4] = r;#。a3; ..a2:__ fillbuf_m(); a == - 1#.c6; ..a3:al!= 10#.c5; // arriva fino a''\ n'' } a = @ buf; A- = j的; CLC; #.c7; // risposta negativa ..c6:a = @ buf; A- = j的; stc; ..c7:Careful thought library functions are importanti think that for tame (domare) the input stream are usefulfunction like these i use.i don''t know if they are rightNote: when ask input: is need a range for validate that(for at last integers, float and double); int cf(void);_cf:mov eax, 0adc eax, 0ret/* int __stdcall getl_m(void* buf, int sz, FILE_m* file);/* legge da "file" una linea di al massimo sz-1 chars/* (ove sz è la size di buf)/* e la mette nel buffer buf la termina con ''\0''/* se errori di parametro ritorna 0 CF=0/* se i caratteri della linea/* eccedono i sz-1 chars ritorna -(lunghezza/* della stringa) e continua a leggere dal file fino a che trova ''\n''/* altrimenti ritorna la lunghezza della stringa/* se incontra EOF CF=1 altrimenti CF=0/* s= 0k, 4k, 8j, 12r, 16c, 20b, 24ra, 28P_buf, 32P_siz, 36P_filegetl_m:push ebxpush ecxpush edxpush edipush ebppush ebp%define @buf [esp+28]%define @sz [esp+32]%define @file [esp+36]mov ebx, @filemov ebp, @szmov edi, @bufxor eax, eaxcmp ebp, 0jle .c0mov [esp], ebxcmp edi, 0je .c0cmp ebp, 1je .c4mov byte[edi], 0 ;/ k=2; --k=1cmp ebx, 0je .c0jmp short .c3..c0:clcjmp .c7..c2:mov eax, edimov byte[edi], 0sub eax, @bufstcjmp .c7..b0:inc edi..c3:dec dword[ebx]jl .a0mov edx, [ebx+4]mov al, [edx]inc edxmov [ebx+4], edxjmp short .a1..a0:call __fillbuf_mcmp eax, -1je .c2..a1:mov [edi], aldec ebpjz .c4cmp al, 10jne .b0inc edimov eax, edimov byte[edi], 0sub eax, @bufclcjmp short .c7..c4:mov byte[edi], 0..c5:dec dword[ebx]jl .a2mov edx, [ebx+4]mov al, [edx]inc edxmov [ebx+4], edxjmp short .a3..a2:call __fillbuf_mcmp eax, -1je .c6..a3: ;/ arriva fino a ''\n''cmp al, 10jne .c5mov eax, @buf ;/ risposta negativasub eax, ediclcjmp short .c7..c6:mov eax, @bufsub eax, edistc..c7:%undef @buf%undef @sz%undef @filepop ebppop ebppop edipop edxpop ecxpop ebxret 12/* int cf(void);_cf: a=0; a++=0; retgetl_m:< b, c, r, j, k, k<< @buf=[s+28], @sz=[s+32], @file=[s+36]b=@file; k=@sz; j=@buf; a^=a;k<=0?#.c0; *s=b; j==0#.c0; k==1#.c4;B*j=0; b==0#.c0; #.c3; // k=2; --k=1..c0: clc; ##.c7;..c2: a=j; B*j=0; a-=@buf; stc; ##.c7;..b0: { ++j;..c3: --D[b]; !>=?#.a0| r=[b+4]; al=*r; ++r; [b+4]=r;#.a1;..a0: __fillbuf_m(); a==-1#.c2;..a1: *j=al; --k!#.c4; al!=10#.b0;}++j; a=j; B*j=0; a-=@buf; clc; #.c7;..c4: B*j=0;..c5: {--D[b]; !>=?#.a2| r=[b+4]; al=*r; ++r; [b+4]=r;#.a3;..a2: __fillbuf_m(); a==-1#.c6;..a3: al!=10#.c5; // arriva fino a ''\n''}a=@buf; a-=j; clc; #.c7; // risposta negativa..c6: a=@buf; a-=j; stc;..c7: > @buf,@ sz,@ file> @buf, @sz, @file b,c,r,j,k,kb, c, r, j, k, k ret 12 // se ritorna 1 = valore preso in val // altrimenti valore non preso int get_double(double * val,double min,double max,FILE_m * pf) {char a [512]; int k,i = 0,cf1; la0:; k = getl_m(a,512,pf); cf1 = cf(); if(k == 0){if(cf1 == 1) {laa:;的printf(QUOT; \\\");返回0;} printf(Errore linea troppo lunga); goto la2; } if((k = sscanf_m(a,"%f",val))!= 1) if(cf1 == 1)goto laa; if(k!= 1 || * val< min || * val> max) {la1:; printf(Errore o importo fuori range); la2:; if(++ i> = 3)goto laa; printf(":Riprova"); goto la0; } 返回1; } int get_int(int * val,int min,int max,FILE_m * pf) {char a [512]; int k,i = 0,cf1; la0:; k = getl_m(a,512,pf); cf1 = cf(); if(k == 0){if(cf1 == 1) {laa:;的printf(QUOT; \\\");返回0;} printf(Errore linea troppo lunga); goto la2; } if((k = sscanf_m(a,"%i",val))!= 1) if(cf1 == 1)goto laa; if(k!= 1 || * val< min || * val> max) {la1:; printf(Errore o importo fuori range); la2:; if(++ i> = 3)goto laa; printf(":Riprova"); goto la0; } 返回1; } int get_uns(uns * val,uns min,uns max,FILE_m * pf) {char a [512]; int k,i = 0,cf1; la0:; k = getl_m(a,512,pf); cf1 = cf(); if(k == 0){if(cf1 == 1) {laa:;的printf(QUOT; \\\");返回0;} printf(Errore linea troppo lunga); goto la2; } if((k = sscanf_m(a,"%u",val))!= 1) if(cf1 == 1)goto laa; if(k!= 1 || * val< min || * val> max) {la1:; printf(Errore o importo fuori range); la2:; if(++ i> = 3)goto laa; printf(":Riprova"); goto la0; } 返回1; } int get_char(char * val,FILE_m * pf) {char a [512]; int k,i = 0,cf1; la0:; k = getl_m(a,512,pf); cf1 = cf(); if(k == 0){if(cf1 == 1) {laa:;的printf(QUOT; \\\");返回0;} printf(Errore linea troppo lunga); goto la2; } if((k = sscanf_m(a,"%c",val))!= 1) if(cf1 == 1)goto laa; if(k!= 1) {la1:; printf(" Errore "); la2:; if(++ i> = 3)goto laa; printf(":Riprova" ;); 转到la0; } 返回1; } // se ritorna 1 = valore preso in val // altrimenti valore non preso // fail met stream in non lo stream al al massimo // ERR对抗EOF // se il sistema esterno ha lo stream in FAIL // non continua int get(num * val,istream& istr) {int i = 0,c; num r; if(istr.f-> flag&(_ERR | _EOF | _FAIL))返回0; nuova:; istr> r; if(istr.f-> flag& _FAIL) {if(istr.f-> flag&(_ERR | _EOF))返回0; do {c = fgetc_m(istr.f);} whil e(c!= EOF&& c!=''\ n''); 如果(c == EOF)返回0; printf(&Errore); if(++ i> = 3) {istr.f-> flag& = ~_FAIL;返回0;} istr.f-> flag& = ~_FAIL; printf(":Riprova"); goto nuova; } * val = r; do {c = fgetc_m(istr.f);} while(c!= EOF&& c!=''\ n''); 返回1; }ret 12// se ritorna 1=valore preso in val// altrimenti valore non presointget_double(double* val, double min, double max, FILE_m* pf){char a[512];int k, i=0, cf1;la0:;k=getl_m(a, 512, pf); cf1=cf();if(k==0){if(cf1==1){laa:; printf("\n"); return 0;}printf("Errore linea troppo lunga"); goto la2;}if( (k=sscanf_m(a, "%f", val))!= 1 )if(cf1==1) goto laa;if(k!=1||*val<min||*val>max){la1:;printf("Errore o importo fuori range");la2:;if(++i>=3) goto laa;printf(": Riprova ");goto la0;}return 1;}intget_int(int* val, int min, int max, FILE_m* pf){char a[512];int k, i=0, cf1;la0:;k=getl_m(a, 512, pf); cf1=cf();if(k==0){if(cf1==1){laa:; printf("\n"); return 0;}printf("Errore linea troppo lunga"); goto la2;}if( (k=sscanf_m(a, "%i", val))!=1 )if(cf1==1) goto laa;if( k!=1 || *val<min || *val>max){la1:;printf("Errore o importo fuori range");la2:;if(++i>=3) goto laa;printf(": Riprova ");goto la0;}return 1;}intget_uns(uns* val, uns min, uns max, FILE_m* pf){char a[512];int k, i=0, cf1;la0:;k=getl_m(a, 512, pf); cf1=cf();if(k==0){if(cf1==1){laa:; printf("\n"); return 0;}printf("Errore linea troppo lunga"); goto la2;}if( (k=sscanf_m(a, "%u", val))!=1 )if(cf1==1) goto laa;if( k!=1 || *val<min || *val>max){la1:;printf("Errore o importo fuori range");la2:;if(++i>=3) goto laa;printf(": Riprova ");goto la0;}return 1;}int get_char(char* val, FILE_m* pf){char a[512];int k, i=0, cf1;la0:;k=getl_m(a, 512, pf); cf1=cf();if(k==0){if(cf1==1){laa:; printf("\n"); return 0;}printf("Errore linea troppo lunga"); goto la2;}if( (k=sscanf_m(a, "%c", val))!=1 )if(cf1==1) goto laa;if( k!=1 ){la1:;printf("Errore ");la2:;if(++i>=3) goto laa;printf(": Riprova ");goto la0;}return 1;}// se ritorna 1=valore preso in val// altrimenti valore non preso// non mette in fail lo stream al massimo// ERR oppure EOF// se il sistema esterno ha lo stream in FAIL// non continuaint get(num* val, istream& istr){int i=0, c;num r;if(istr.f->flag & ( _ERR | _EOF | _FAIL )) return 0;nuova:;istr >r;if( istr.f->flag & _FAIL ){ if(istr.f->flag & ( _ERR | _EOF) ) return 0;do{c=fgetc_m(istr.f);}while(c!=EOF && c!=''\n'');if(c==EOF) return 0;printf("Errore ");if(++i>=3){istr.f->flag &= ~ _FAIL; return 0;}istr.f->flag &= ~ _FAIL;printf(": Riprova "); goto nuova;}*val=r;do{c=fgetc_m(istr.f);}while(c!=EOF && c!=''\n'');return 1;}推荐答案"?a \\ / b" < [email protected]:"?a\\/b" <[email protected]: 认真思考库函数很重要 i认为对于tame(domare)输入流是有用的 功能就像我使用的那样。 i不知道他们是对的 注意:当问输入时:是需要一个范围来验证 (最后整数,浮动和双倍) ; int cf(void); _cf: mov eax,0 adc eax,0 retCareful thought library functions are importanti think that for tame (domare) the input stream are usefulfunction like these i use.i don''t know if they are rightNote: when ask input: is need a range for validate that(for at last integers, float and double) ; int cf(void);_cf: mov eax, 0 adc eax, 0 ret [删除了274行] 你和av< [email protected]>是同一个人;",也称为 " RoSsIaCrIiLoIA",不是吗? 如果你打算坚持发布这个废话在这里,请至少 有一个简单的礼貌使用一致的名称,所以那些不想b / b $ b $想要阅读它的人可以正确地杀死你。 或者更好的是,停止在comp.lang.c中发布汇编语言。 - Keith Thompson(The_Other_Keith) ks***@mib.org < http://www.ghoti.net/~kst> 圣地亚哥超级计算机中心< *< http://users.sdsc.edu/~kst> 我们必须做点什么。这是事情。因此,我们必须这样做。[274 lines deleted]You''re the same person as "av <[email protected]>", also known as"RoSsIaCrIiLoIA", aren''t you?If you''re going to insist on posting this crap here, please at leasthave the simple courtesy to use a consistent name so those who don''twant to read it can killfile you properly.Or better yet, stop posting assembly language in comp.lang.c.--Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>We must do something. This is something. Therefore, we must do this. 2006年9月13日星期三21:06:03 +0200,?a \ / / b写道:On Wed, 13 Sep 2006 21:06:03 +0200, ?a\/b wrote: > int get_double(double * val,double min,double max,FILE_m * pf) {char a [512]; int k,i = 0,cf1; la0:; k = getl_m(a,512,pf); cf1 = cf(); if(k == 0){if(cf1 == 1)>intget_double(double* val, double min, double max, FILE_m* pf){char a[512];int k, i=0, cf1;la0:;k=getl_m(a, 512, pf); cf1=cf();if(k==0){if(cf1==1) 或许更好 if(k 与其他人相同perhaps betterif(k<=0)the same for others {laa:;的printf(QUOT; \\\");返回0;} printf(Errore linea troppo lunga); goto la2; } {laa:; printf("\n"); return 0;} printf("Errore linea troppo lunga"); goto la2; } 2006年9月13日星期三19:53:13 GMT,Keith Thompson写道:On Wed, 13 Sep 2006 19:53:13 GMT, Keith Thompson wrote: >"?a\\ / b" < [email protected]:>"?a\\/b" <[email protected]: >认真思考库函数很重要我认为对于tame(domare)输入流是有用的我不知道他们是不对的 注意:当询问输入时:需要一个范围来验证(对于最后整数,浮动和双倍) ; int cf(void); _cf: mov eax,0 adc eax,0 ret>Careful thought library functions are importanti think that for tame (domare) the input stream are usefulfunction like these i use.i don''t know if they are rightNote: when ask input: is need a range for validate that(for at last integers, float and double) ; int cf(void);_cf: mov eax, 0 adc eax, 0 ret [已删除274行] 你和av< [email protected]>同名,也被称为RoSsIaCrIiLoIA,不是吗? 如果你要坚持在这里发布这个废话,[274 lines deleted]You''re the same person as "av <[email protected]>", also known as"RoSsIaCrIiLoIA", aren''t you?If you''re going to insist on posting this crap here, 它不是垃圾it is not "crap" >请至少有一个简单的礼貌使用一致的名称,所以那些不想读它的人可以正确地杀死你。>please at leasthave the simple courtesy to use a consistent name so those who don''twant to read it can killfile you properly. 如果你不想读:不读......if you don''t like to read: don''t read ... >或者更好的是,停止在comp.lang.c中发布汇编语言。>Or better yet, stop posting assembly language in comp.lang.c. 这篇关于C语言缺少键盘输入功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-23 03:13