Hey im new to these forums && know little about C++ i made this program that uses enum and it decides what to write But the problem is as soon as i type a number in, the program closes i've tried SYSTEM("PAUSE");, the pause>nul etc get cin() or what ever it is. Heres the code.
# include <iostream.h>
# include <conio.h>
int main()
{
enum Days { Monday = 1, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday };
Days DayOff;
int x;
cout << "What day would you like off? (1 - 7) : ";
cin >> x;
DayOff = Days(x);
if (DayOff == Saturday || DayOff == Sunday)
cout << "Your already off on weekends..\n";
else
cout << "Have a nice holday! Your allowed off";
getch();
return 0;
}
there is another way
not to pause the screen but repeat the program using some loops and sellection statements:
i usually use the debugger to find logical or memory bugs like this.
or you'd probably like to insert pauses inbetween the code, instead of just at the end. and enable some cout like after Dayoff = Day(x);, insert a line like cout >> "break1" >> endl; den system pause. coz (juz a reminder that) the code runs top down...