Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C, flushing the buffer

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Unbr0ken
Advanced Cheater
Reputation: 2

Joined: 10 Aug 2011
Posts: 67

PostPosted: Sat Aug 18, 2012 1:36 am    Post subject: C, flushing the buffer Reply with quote

Is there a POSIX/ANSI way to flush the stdin?

Code:
fflush(stdin); //should not be used.
setbuf(stdin, NULL); //Doesn't work on linux.
while((C = getchar()) != '\n' && C != EOF) //This is just an implementation, I need a standard function.
fseek(stdin, 0, SEEK_END); //Same as setbuf


So, Is there another way?

Thanks for reading. Wink
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sat Aug 18, 2012 11:21 pm    Post subject: Reply with quote

tried fpurge?
Back to top
View user's profile Send private message
Unbr0ken
Advanced Cheater
Reputation: 2

Joined: 10 Aug 2011
Posts: 67

PostPosted: Sat Aug 18, 2012 11:34 pm    Post subject: Reply with quote

fpurge is non-standard (it's not even POSIX) and extremely non-portable; even on systems that support it, it's not recommended.

But thanks for trying to help.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Aug 19, 2012 9:56 am    Post subject: Reply with quote

i know that. just pointing out the common alternative. there is no portable way to do what you want (other than the code you have already posted). tcflush might be closer to what you are looking for
Back to top
View user's profile Send private message
Unbr0ken
Advanced Cheater
Reputation: 2

Joined: 10 Aug 2011
Posts: 67

PostPosted: Sun Aug 19, 2012 2:11 pm    Post subject: Reply with quote

Well, I finally had to use the implementation. It's the closest way to a standard.

Thanks for help.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites