Theo standard C library, thi` "scanf" tru+~ data tu+` stdin va`o argument 
"str[80]" chu+'  kho^ng co`n dde^? trong keyboard buffer  ma` ba.n 
"fflush(stdin)".
DDe^` nghi. reset "str[80]"  cho la^`n thu+' hai, thay vi` fflush(stdin).

-----------------------------------------------
> Date: Tue, 12 Sep 2006 07:42:08 -0700
> From: [EMAIL PROTECTED]
> To: vietlug-users@lists.sourceforge.net
> Subject: Re: [Vietlug] day la doan text tui dinh gui len
> 
> theo tui duoc biet thi no khong he co tac dung vi du co hay ko co thi ket qua 
> van vay!!! Hic  help me
> Hong Tran Duc <[EMAIL PROTECTED]> wrote:
> #include "stdio.h"
> int main()
> {
> char str[80];
> printf("Enter some words: ");
> scanf("%s", str);
> printf("The first word you entered is : %s\n", str );
> fflush(stdin); //is it work ?
> printf("Enter some words: ");
> scanf("%s", str);
> printf("The first word you entered is : %s\n", str );
> return 0;
> }
> On 9/12/06, Larry Nguyen wrote:
> > On 5:50:50 am 09/11/06 hong pham wrote:
> > >
> > >
> > > Stay in the know. Pulse on the new Yahoo.com. Check it
> > out.
> >
> > Gu+?i la.i du`m Hong Pham
> >
> > Mình vừa gặp phải một lỗi rất khó hiểu. Đây là đoạn
> > mã nguồn của mình:
> > #include "stdio.h"
> >
> > int main()
> > {
> > char str[80];
> > printf("Enter some words: ");
> > scanf("%s", str);
> > printf("The first word you entered is : %s\n", str );
> >
> > printf("Enter some words: ");
> > scanf("%s", str);
> > printf("The first word you entered is : %s\n", str );
> >
> > return 0;
> > }
> > và đây là kết quả mà mình mong đợi:
> > "Enter some words:hello word
> > The first word you entered is:hello
> > Enter some words:who are u?
> > The first word you entered is:who"
> > nhưng kết quả mà mình thu được lại là:
> > "Enter some words: hello word
> > The first word you entered is : hello
> > Enter some words: The first word you entered is : word"
> > Không thể hiểu nổi tại sao hàm scanf() lại chỉ hoạt động
> > đúng một lần. Ngay cả khi mình đã sử dụng hàm fflush(stdin)
> > nhưng kết quả vẫn như cũ. Ai đó giúp mình với. Mình xin
> > cám ơn!!!
> >
> >
> > -------------------------------------------------------------------------
> > Using Tomcat but need to do more? Need to support web services, security?
> > Get stuff done quickly with pre-integrated technology to make your job 
> > easier
> > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > _______________________________________________
> > VietLUG-users mailing list
> > VietLUG-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/vietlug-users
> >
> --
> nm.
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> VietLUG-users mailing list
> VietLUG-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/vietlug-users
> -----------------------------------------------
> Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ 
> countries) for 2/min or less.

_________________________________________________________________
Express yourself with gadgets on Windows Live Spaces
http://discoverspaces.live.com?source=hmtag1&loc=us
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
VietLUG-users mailing list
VietLUG-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vietlug-users

Trả lời cho