I have this program in c++:
#include <iostream> using namespace std; int main() { char buf[50]; cin.getline(buf,49); system(buf); return 0; }
When I run and compile it and type for example ‘helo’, my program prints the error:
'helo' not found.
Can I stop this error from being displayed? Is there any way to disable the error from the system command?
You can’t change the way
systemdisplays errors. C and C++ put very little to no requirements on implementations in that regard, so that large parts of it are left unspecified, to allow them to be as flexible as possible.If you want more precise control, you should use the functions of your runtime library or operation system interface. Try
execvp(seeman execvp) in linux/unix or the CreateProcess function for windows systems, which uses the Windows API that allows great control over error handling and other stuff.