I am in the process of self-teaching C++ using a complex Lotto Program for exercise work. I keep getting an error in one section stating that I've used an illegal digit "08" & "09" and I do not know why. My program is:
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <ios>
#include <algorithm>
using namespace std;
int main ()
{
/* =========================================================================================================================== */
Start:
char z;
cout << "For Florida MegaMillion press #1" << endl << endl;
cout << "For Florida Lotto press #2" << endl << endl;
cout << "For National Power-Ball press #3" << endl << endl;
cout << "To start over press #4" << endl << endl;
cin >> z;
if (z == 1)
{
cout << "You have chosen to play Florida's MegaMillion Lotto," << endl << endl;
goto MegaMillion;
}
else
if (z == 2)
{
cout << "You have chosen to play the Florida Lotto." << endl << endl;
goto FloridaLotto;
}
else
if (z == 3)
{
cout << "You have chosen to play the National Power-Ball Lotto," << endl << endl;
goto PowerBall;
}
else
if (z == 4) goto Start;
else
if (z != 1 && z != 2 && z != 3 && z != 4)
{
cout << "You have chosen to end the program." << endl << endl;
return 0;
}
/* ================================================================================================================================*/
MegaMillion:
char x;
char str [6];
#define Anydate(); // Declare / define the variable Anydate.
#define date
#define number
/*
{
Anydate();
Anydate(string,[6]);
~Anydate();
string date;
int number[6];
};
Anydate=Anydate(string thatdate, int thatnumber[6]);
{
date=thatdate;
for(int i=0;i!=6;i++);
number[i]=thatnumber[i];
}
Anydate=Anydate();
Anydate=~Anydate();
*/
// initialize 44 variables to receive and count the numbers from 1 thru 44
int n01=0; int n02=0; int n03=0; int n04=0; int n05=0; int n06=0; int n07=0; int n08=0; int n09=0; int n10=0; int n11=0; int n12=0;
int n13=0; int n14=0; int n15=0; int n16=0; int n17=0; int n18=0; int n19=0; int n20=0; int n21=0; int n22=0; int n23=0; int n24=0;
int n25=0; int n26=0; int n27=0; int n28=0; int n29=0; int n30=0; int n31=0; int n32=0; int n33=0; int n34=0; int n35=0; int n36=0;
int n37=0; int n38=0; int n39=0; int n40=0; int n41=0; int n42=0; int n43=0; int n44=0;
ifstream a_file ( "D:\ LotteryProgram / MegaMill" ); //Opens MegaMill for reading the file
a_file >> str; //Reads one string from the file MegaMill
ofstream b_file ( "D:\ LotteryPrograms/ MegaNum" ); //Creates an instance of ofstream, and opens the file MegaNum.
b_file << "Anydate"; // Outputs to MegaNum through b_file.
b_file << "x";
b_file.close(); // Close the file stream explicitly.
{
if (x == 01) n01++; if (x == 02) n02++; if (x == 03) n03++; if (x == 04) n04++; if (x == 05) n05++; if (x == 06) n06++; if (x == 07) n07++;
if (x == 08) n08++; if (x == 09) n09++; if (x == 10) n10++; if (x == 11) n11++; if (x == 12) n12++; if (x == 13) n13++; if (x == 14) n14++;
if (x == 15) n15++; if (x == 16) n16++; if (x == 17) n17++; if (x == 18) n18++; if (x == 19) n19++; if (x == 20) n20++; if (x == 21) n21++;
if (x == 22) n22++; if (x == 23) n23++; if (x == 24) n24++; if (x == 25) n25++; if (x == 26) n26++; if (x == 27) n27++; if (x == 28) n28++;
if (x == 29) n29++; if (x == 30) n30++; if (x == 31) n31++; if (x == 32) n32++; if (x == 33) n33++; if (x == 34) n34++; if (x == 35) n35++;
if (x == 36) n36++; if (x == 37) n37++; if (x == 38) n38++; if (x == 39) n39++; if (x == 40) n40++; if (x == 41) n41++; if (x == 42) n42++;
if (x == 43) n43++; if (x == 44) n44++;
}
// This is where I'm getting illegal 08 & 09 digits... why?
/* ================================================================================================================================== */
FloridaLotto:
char u;
cout << "This part works just fine" << endl << endl << "Press 'y' to continue" << endl << endl << "Press 'n' to exit program";
cin >> u;
if (u == 'y')
{ cout << "You have chosen to start over again";
goto Start;
}
if (u == 'n')
{
cout << "You have chosen to end the program." << endl << endl;
return 0;
}
if (u != 'y' && u != 'n')
{
cout << "Hey dummy, What part of 'y' or 'n' did you fail to understand?" << endl << endl;
goto Start;
}
/* =========================================================================================================================== */
PowerBall:
char m;
cout << "This part works just fine" << endl << endl << "Press 'y' to continue" << endl << endl << "Press 'n' to exit program";
cin >> m;
if (m == 'y')
{ cout << "You have chosen to start over again";
goto Start;
}
if (m == 'n')
{
cout << "You have chosen to end the program." << endl << endl;
return 0;
}
if (m != 'y' && m != 'n')
{
cout << "Hey dummy, What part of 'y' or 'n' did you fail to understand?" << endl << endl;
goto Start;
}
return 0;
}