you have to
#include <limits>
at the top or this code should not compile.. dd it compile without it?
I am not very good with c++.
i found that the "istream" object "cin" still contains the value '\n' from the last call to "cin".. in your program. you can test this by adding
1 2
|
char lastChar = cin.get();
cout<<endl<< "last=|"<<lastChar<<"|"<<endl;
|
between the lines 24 and 25..
so, thats why the cin.ignore() function exits suddenly...
your program works fine...
to overcome the problem, just waste this last character by adding something like
char lastChar = cin.get();
between 24 - 25 lines..
or there maybe a more legit way to destroy the values within "cin" which i dont know.
ps.
i recommend using visual studio (or Anjuta if u r in linux).... you can get VS for free, non-commercial Express version.. for students..
its very good for debugging..
cheers....