Hello, I am writing an app to take in user name and bday, then return zodiac and birthstone..I am attempting to separate it into functions, am using switch, andgetting a "missing ; before switch" error, I can't see it, noone else in class can see where one is missing either. Help!
Here is the error statement:
Compiling...
UserBday.cpp
C:\Documents and Settings\Kevin Schuth\Desktop\KSchuth Final\Final\UserBday.cpp(8) : error C2143: syntax error : missing ';' before 'switch'
C:\Documents and Settings\Kevin Schuth\Desktop\KSchuth Final\Final\UserBday.cpp(9) : error C2447: missing function header (old-style formal list?)
Zodiac.cpp
C:\Documents and Settings\Kevin Schuth\Desktop\KSchuth Final\Final\Zodiac.cpp(8) : error C2143: syntax error : missing ';' before 'switch'
C:\Documents and Settings\Kevin Schuth\Desktop\KSchuth Final\Final\Zodiac.cpp(9) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
Final.exe - 4 error(s), 0 warning(s)
and the code main is here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include <iostream>
#include <string>
using namespace::std;
extern void UserBday (int, int, int);
extern void Zodiac (int, int);
extern void main(void);
extern void main()
{
// get user name
string UName;
cout<<"Please enter your name: ";
cin>> UName;
cout<< "Hello "<< UName << "!\n";
// get user birthdate
int m, d, y;
{
cout<<"Please enter your birthdate in numerical form: "<<endl;
cin>> m >> d >> y;
UserBday ( m,d,y );
Zodiac ( m,d );
}
}
|
One of the functions code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include <iostream>
using namespace::std;
void UserBday (int m, int d, int y);
switch(m);
{
case 1:
if(m=1)
cout<<"You were born on January "<<d<< " in the year "<<y<<endl;
break;
case 2:
if(m=2)
cout<<"You were born on February "<<d<< " in the year "<<y<<endl;
break;
case 3:
if(m=3)
cout<<"You were born on March "<<d<< " in the year "<<y<<endl;
break;
case 4:
if(m=4)
cout<<"You were born on April "<<d<< " in the year "<<y<<endl;
break;
case 5:
if(m=5)
cout<<"You were born on May "<<d<< " in the year "<<y<<endl;
break;
case 6:
if(m=6)
cout<<"You were born on June "<<d<< " in the year "<<y<<endl;
break;
case 7:
if(m=7)
cout<<"You were born on July "<<d<< " in the year "<<y<<endl;
break;
case 8:
if(m=8)
cout<<"You were born on August "<<d<< " in the year "<<y<<endl;
break;
case 9:
if(m=9)
cout<<"You were born on September "<<d<< " in the year "<<y<<endl;
break;
case 10:
if(m=10)
cout<<"You were born on October "<<d<< " in the year "<<y<<endl;
break;
case 11:
if(m=11)
cout<<"You were born on November "<<d<< " in the year "<<y<<endl;
break;
case 12:
if(m=12)
cout<<"You were born on December "<<d<< " in the year "<<y<<endl<<endl;
break;
}
|
Both the Bday and the Zodiac cpp get this same error...
Thanks