I have encountered weird behaviour with character arrays/strings on various websites. For example take these two submissions — [First submission](http://codeforces.me/contest/572/submission/13292716) [Second submission](http://codeforces.me/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.me/problemset/problem/591/B). [This submission](http://codeforces.me/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.me/contest/591/submission/13918178) with fflush(stdin) and scanf also got runtime error. But [this submission](http://codeforces.me/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.
↵
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.