windows - Displaying 0 when using system("") command in c++ -


i new c++ , making basic login system... although when cout "incorrect password" , change colour of text using system("color 4") red, displays 0 before it. has had problem before , if so, how did resolve it. =)

cout << endl << system("color 4") << "incorrect password"; 

you printing return code of system(), implementation-defined value, platforms 0 on successful completion of command.

the code told do. ;-)

you could execute system() call before cout line. (if works you.)

generally speaking, system() should avoided. it's crutch "i don't know how properly", it's platform-dependent, , beginners fail check return value (which "implementation-defined" boot), making program prone silent failures of whatever program wants (attempt to) call.


Comments