//purpose: to reverse the order of a word or a sentence. eg) program -> margorp.
#include <iostream>
usingnamespace std;
void msg()
{
char ch;
cin.get(ch);
if (ch != '.')
{
msg();
}
cout << ch;
}
int main()
{
msg();
system ("pause");
return 0;
}
as you can see if I declare the variable (ch) as global, the program will output dots (.) corresponding to how many characters that I've inputted.
If ch is global it contains the very last input character which is the dot, otherwise you won't see any output.
if ch is local it is pushed/popped to/from the stack each time msg() is called.