有那位帮我解释一下!!ch = getchar() !!!!!
--- e:\my documents\visual studio projects\test_5\test_5.cpp -------------------
1: #include <stdio.h>
2: #include <conio.h>
3:
4: int main()
5: {
00411A50 push ebp
00411A51 mov ebp,esp
00411A53 sub esp,0D0h
00411A59 push ebx
00411A5A push esi
00411A5B push edi
00411A5C lea edi,[ebp-0D0h]
00411A62 mov ecx,34h
00411A67 mov eax,0CCCCCCCCh
00411A6C rep stos dword ptr [edi]
6: char ch;
7: ch = getchar();
00411A6E mov eax,dword ptr [__iob+4 (428B44h)]
00411A73 sub eax,1
00411A76 mov dword ptr [__iob+4 (428B44h)],eax
00411A7B js main+51h (411AA1h)
00411A7D mov ecx,dword ptr [__iob (428B40h)]
00411A83 movsx edx,byte ptr [ecx]
00411A86 and edx,0FFh
00411A8C mov dword ptr [ebp-0D0h],edx
00411A92 mov eax,dword ptr [__iob (428B40h)]
00411A97 add eax,1
00411A9A mov dword ptr [__iob (428B40h)],eax
00411A9F jmp main+64h (411AB4h)
00411AA1 push offset __iob (428B40h)
00411AA6 call @ILT+730(__filbuf) (4112DFh)
00411AAB add esp,4
00411AAE mov dword ptr [ebp-0D0h],eax
00411AB4 mov cl,byte ptr [ebp-0D0h]
00411ABA mov byte ptr [ch],cl
8: return 0;
00411ABD xor eax,eax
9: }
00411ABF pop edi
00411AC0 pop esi
00411AC1 pop ebx
00411AC2 add esp,0D0h
00411AC8 cmp ebp,esp
00411ACA call @ILT+950(__RTC_CheckEsp) (4113BBh)
00411ACF mov esp,ebp
00411AD1 pop ebp
00411AD2 ret
7: ch = getchar(); 到底为我们做了什么?汇编的操作是什么意思?谢谢!!!!
问题点数:20、回复次数:6Top
1 楼yegaofei(踏雪而歌)回复于 2004-12-04 12:49:56 得分 2
我记得gethcar()就是从输入缓冲里取一个字符,并返回该字符Top
2 楼hcj2002(流浪者·躬自厚而薄责于人 )回复于 2004-12-04 13:10:03 得分 2
从stdin中读取一个字符。Top
3 楼sharkhuang(走吧走吧!人总会慢慢长大~)回复于 2004-12-04 13:13:49 得分 10
Administrator@SZ-CS-SHARKH1 ~
$ man getchar
getchar(3) getchar(3)
NAME
getchar - read a character (macro)
ANSI_SYNOPSIS
#include <stdio.h>
int getchar(void);
int _getchar_r(void * reent);
TRAD_SYNOPSIS
#include <stdio.h>
int getchar();
int _getchar_r( reent)
char * reent;
DESCRIPTION
getchar is a macro, defined in stdio.h. You can use
getchar to get the next single character from the standard
input stream. As a side effect, getchar advances the
standard input's current position indicator.
The alternate function _getchar_r is a reentrant version.
The extra argument reent is a pointer to a reentrancy
structure.
RETURNS
The next character (read as an unsignedchar, and cast to
int), unless there is no more data, or the host system
reports a read error; in either of these situations,
getchar returns EOF.
You can distinguish the two situations that cause an EOF
result by using ` ferror(stdin)' and ` feof(stdin)'.
PORTABILITY
ANSI C requires getchar; it suggests, but does not
require, that getchar be implemented as a macro.
Supporting OS subroutines required: close, fstat, isatty,
lseek, read, sbrk, write.
SOURCE
src/newlib/libc/stdio/getchar.c
getchar(3)
(END)Top
4 楼williamVII(spread)回复于 2004-12-04 16:23:05 得分 2
how?Top
5 楼Flood1984(峰子)回复于 2004-12-04 17:10:56 得分 2
getchar();
从标准输入设备读取一个字符,并返回字符的ASCII值Top
6 楼sun428(Born to Win)回复于 2004-12-11 12:03:31 得分 2
getchar
功 能: 从stdin流中读字符Top




