Originally posted by maes
I don't want to be an ******* for correcting you, but fflush(stdin) can invoke undefined behaviour you can use while (getchar() != '\n'); instead. void main can also produce undefined behaviour so use int main() and put return 0; at the end of your program
About your program, this might help you a bit
Well first of all watch your language in our forums.
Second of all you better know what you are talking about before correcting someone. Using void main() is fine as long as it is part of the language of the particular compiler that you are using. And yes there is more than one C++ compiler, quite a few actually. Using void main() was how main was declared in C but in C++ depending on which compiler you use it can be declared as void main() or int main(). I imagine that Xiang is using a compiler that accepts void main() since obviously he has compiled and ran his program already but just didn't get the output he wanted.