Problem with fflush and scanf in C/C++
Difference between en1 and en2, changed 131 character(s)
I have encountered weird behaviour with character arrays/strings on various websites. For example take these two submissions — [First submission](http://codeforces.com/contest/572/submission/13292716) [Second submission](http://codeforces.com/contest/572/submission/14574115). I have just removed fflush(stdin) from my first submission and got AC. I faced similar issue with [this problem](http://codeforces.com/problemset/problem/591/B). [This submission](http://codeforces.com/contest/591/submission/13918008) has scanf without fflush(stdin) and it got runtime error but according to previous logic it should have got AC. Now [this submission](http://codeforces.com/contest/591/submission/13918178) with fflush(stdin) and scanf also got runtime error. But [this submission](http://codeforces.com/contest/591/submission/13918022) with cin got AC.↵

So my question is what should i do to prevent such nasty errors during contest? cin is slower than scanf so i prefer scanf.



EDIT — For first problem, i saw that i have used different versions of C++. In C++ 11 it gave WA but in C++ it gave AC.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English dush1729 2015-11-30 20:28:01 131
en1 English dush1729 2015-11-30 20:23:15 1018 Initial revision (published)