Ariya Hidayat wrote:
Memang tidak analogous, karena stdout justru mengambil semua,fflush(stdin); Apakah function itu bs digunakan? Jika ya, thanks to Agus Budy Wuysang for telling me this trick *^_^*
Nggak bisa :-( Silakan coba sendiri, atau perhatikan yang ini dari C-Faq:
"fflush is defined only for output streams. Since its definition of flush is to complete the writing of buffered characters (not to discard them), discarding unread input would not be an analogous meaning for fflush on input streams."
sedangkan stdin membuang sisa.
... cont ...
There is no standard way to discard unread characters from a stdio input stream, nor would such a way be sufficient unread characters can also accumulate in other, OS-level input buffers.
Yah begitulah tidak ada standard way, tapi jalan beberapa
system yang sudah dicoba sendiri: linux, Pyramid, DEC ultrix,
Alpha/OSF1, SCO ODT3 & Openserver 5, Unixware 2.01, SGI Irix.
Di linux ada __fpurge() & fpurge() adopsi dari BSD, yang juga
mengadopsi dari Slowaris :)
while (getchar() != '\n'); gagal kalau pas baris terakhir
ditutup dengan <EOF>
int c;while (((c = getchar()) != '\n') && c != EOF);
hampir jalan, tapi juga mungkin gagal untuk double byte locale
character, eg huruf kanji :(
--
+-R-| Mozilla 1.1! Gecko/200208 |-H-| Powered by Linux 2.4.x |-7-+
|/v\ Agus Budy Wuysang MIS Department |
| | Phone: +62-21-344-1316 ext 317 GSM: +62-816-1972-051 |
+------------| http://www.fasw.co.id/person/supes/ |-------------+
--
Utk berhenti langganan, kirim email ke [EMAIL PROTECTED]
Informasi arsip di http://www.linux.or.id/milis.php3
