Hello I am trying to use the system("pause"); comand at the end of my program but it is pausing too early. I want it to pause after it outputs the last if statement, but it dont it pauses right before it. Here is the code of it:
Any segustion on why it isn't working?Code:#include <iostream.h> //for basic input and output #include <string.h> //for !strcmp #include <windows.h> //for the screen clear and colouring void color(int x) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),WORD(x)); } int main() { char *ans1=new char[20]; char *ans2=new char[20]; system("cls"); color(3); cout << "What is your name?: "; cin >> ans1; system("cls"); color(4); cout << "You said your name was "; cout << ans1 << ".\nIs this correct?\nyes/no\n"; cin >> ans2; system("cls"); color(5); if (!strcmp(ans2, "yes")) cout << "Pleased to meet you" << ans1 << "\n\n"; if (!strcmp(ans2, "no")) cout << "Go away if you can't tell me your real name!\n\n"; system("pause"); return(0); }
I am using MSVC++6.0