như tiêu đề thì cho hỏi cách sử dụng hàm fflush để xóa bỏ kí tự Enter
P/s: mình sử dụng CB, compiler là GNU GCC Compiler
vậy cho mình biết cách sử dụng nó được không?
và tiện thì cho biết tại sao codeblock không cho ghi thế này nhỉ
Code:void main()
^ Vì sai chuẩn.
http://www.cplusplus.com/reference/cstdio/fflush/
If the given stream was open for writing (or if it was open for updating and the last i/o operation was an output operation) any unwritten data in its output buffer is written to the file.
If stream is a null pointer, all such streams are flushed.
In all other cases, the behavior depends on the specific library implementation. In some implementations, flushing a stream open for reading causes its input buffer to be cleared (but this is not portable expected behavior).
Đã được chỉnh sửa lần cuối bởi prog10 : 28-12-2014 lúc 07:47 PM.
Theo mình thì để hiểu được fflush thì bạn cần hiểu về stream là gì, buffer là gì, tại sao lại dùng buffer, khi gọi fflush thì việc gì sẽ xảy ra.
KISS
Skype: giapnguyen_bka89
Thử dán đoạn code này vào và chạy 2 lần:
Lần thứ 2 thì bỏ dòng fflush(stdin); xem sao
C Code:
#include "stdio.h" #include <conio.h> int main() { char ten[50]; char dia_chi[50]; int tuoi = 0; getch(); return 0; }
Stay hungry. Stay foolish.
Design is not just what it looks like and feels like. Design is how it works.