I use the following algorithm to display the reverse digits.
However, after I input an integer (actually a series of char), the program does not display them "continuously".
I have to type enter to display every digit.
What is the problem I have made?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <cstdio>
usingnamespace std;
int main()
{
char x;
staticint i = 0;
if (i++ == 0)
cout << "Input an integer to reverse it: ";
while ((x = cin.get()) != '\n')
{
main();
cout << x;
}
}