You really should use third party libraries. There's definitely no platform-independent way to do it in ANSI C. Signal handling is not the way. Some C++ implementations reimplement the standard input stream seperatly from the C stdin stream.