#include <sgtty.h> echo_off() { struct sgttyb state; (void)ioctl(0, (int)TIOCGETP, (char *)&state); state.sg_flags &= ~ECHO; (void)ioctl(0, (int)TIOCSETP, (char *)&state); } echo_on() { struct sgttyb state; (void)ioctl(0, (int)TIOCGETP, (char *)&state); state.sg_flags |= ECHO; (void)ioctl(0, (int)TIOCSETP, (char *)&state); }Once you have defined these functions in your program, you can just call them whenever you want to disable or enable terminal echo.
If you are interested in learning more about the ioctl function, you can read the manual page by using the man command:
man ioctl