First, conio.h is not part of the standard. Previously, Borland and MS supported it, but now it is disabled. Therefore, all the old examples that have this title should be corrected.
I suggest the following: remove lines #include <conio.h> and _getch(); from the program. And replace cprintf with printf . There is also no easy way to set the color, so remove the textbackground and textcolor . After that, she must earn. If this is enough, then good.
If it is necessary that the console does not close immediately, then it is necessary to slightly supplement the program. This can be done, for example, by adding a call to the following function:
#include <iostream> #include <limits> void PressEnterToContinue() { std::cout << "Press ENTER to continue... " << flush; std::cin.ignore( std::numeric_limits <std::streamsize> ::max(), '\n' ); }
Then the program will look something like this:
#include "stdafx.h" #include <stdio.h> #include <iostream> #include <limits> void PressEnterToContinue() { std::cout << "Press ENTER to continue... " << flush; std::cin.ignore( std::numeric_limits <std::streamsize> ::max(), '\n' ); } int main() { float a = 5.5; float b = 1.5; float c = 3.3; printf ("BLA BLA "); PressEnterToContinue(); }