here's what I came up with - I'll post some working code in a sec...
Code:
#include <iostream>
#include <stdlib.h> //change this to cstdlib
using namespace std;
int main(int argc, char *argv[]) //you can use main() if you don't plan on using
{ //command-line input
const int value1 = 0;
const int value2 = 1;
const int value3 = 2;
const int value4 = 3;
int zzz;
int x;
for(int i = 0; i < 5; i++)
{
switch(zzz) //where was zzz initialized?
{
value1: x = value1; break; //you forgot 'case' see next three
case value2: x = value2; break;
case value3: x = value3; break;
case value4: x = value4; break;
default: x = 999; //999 = myHead->rand(); //to show it's NOT of values 1-4
}
cout << x << endl;
}
system("PAUSE"); //avoid using this. try cin.get(); instead.
return 0;
}
working:
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
const int value1 = 0;
const int value2 = 1;
const int value3 = 2;
const int value4 = 3;
int zzz;
int x;
std::cout<<"Enter 5 integers between 0 and 3:"<<std::endl;
for(int i = 0; i < 5; i++)
{
std::cout<<'>';
std::cin>>zzz;
std::cin.ignore();
switch(zzz)
{
case value1: x = value1; break;
case value2: x = value2; break;
case value3: x = value3; break;
case value4: x = value4; break;
default: x = 999; //999 = myHead->rand(); //to show it's NOT of values 1-4
}
cout << x << endl;
}
std::cout<<"Press [ENTER] to exit";
std::cin.get();
return 0;
}