how can i make a function on or off

im doing this function to disable echoing the user input... how can i make a control on/off to this function??

if using a boolean.. how so?

bool echo()
{
DWORD mode;
HANDLE hConIn = GetStdHandle( STD_INPUT_HANDLE );
GetConsoleMode( hConIn, &mode );

if true
{
SetConsoleMode( hConIn, 0 );
}
else if false
{
SetConsoleMode( hConIn, mode );
}
return 0;
}
Something as

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
bool echo( bool on_off )
{
   DWORD mode;
   HANDLE hConIn = GetStdHandle( STD_INPUT_HANDLE );
   GetConsoleMode( hConIn, &mode );

   if ( on_off )
   {
      SetConsoleMode( hConIn, 0 );
   }
   else 
   {
      SetConsoleMode( hConIn, mode );
   }

   return ( on_off ); 
} 
if i want the function to be on..
should i do.. echo(bool on); ?
You should call the function either with boolean literal true or false.

For example

echo( true );

or

echo( false );

Last edited on
it still doesn't work.. =(

echo is still disabled even if i put echo (false) in it..
Not surprising, you have the order wrong.
Topic archived. No new replies allowed.