sorry i have tried EVERY imaginable combo of that am am still getting;
Code:
C:\Program Files\Microsoft Visual Studio\MyProjects_M\Sem_2\4_1\4_1.cpp(125) : error C2664: 'strcmp' : cannot convert parameter 1 from 'char' to 'const char *'
here is the entire program ...if you can:PLEASE help!!
Code:
# include <iomanip>
#include <string>
# include <fstream>
# include <iostream>
using namespace std;
class Month{
public:
void Month::Load(Month[]);
int Month::calcdays(const Month[], int);
int Month::calcdays(const Month[], char*);
void Month:: printResult(const Month[],int, int);
int MonthNumber;
char MonthName[10];
char MonthAbrv[5];
int MonthDays;
};
char month[12][10] = { "January", "February", "March", "April", "May", "June", "July", "August"};
const MAXMONTHS = 12;
//extern file with Month load data
ifstream infile("C:\\CODE\\INF\\3abc\\IF3abc.TXT");
int main ()
{
Month AM[MAXMONTHS];
int nm = 0;
int total = 0;
char month[10];
if (!infile)
{
cerr << "Cannot open input file" << endl;
}//if
else
{
AM[MAXMONTHS].Load(AM);
cout << "\n\n" << setw(55) << "Year-To-Date Number of Days Calculation" << endl;
for (int i = 0; i< MAXMONTHS; i++)
{
cout << "\n\n" << setw(55) << "Enter Number of Month (i.e. Dec = 12): ";
cin >> nm;
total = AM[MAXMONTHS].calcdays(AM, nm);
if (total ==0)
{}//don't print result if entry is invalid
else
{AM[MAXMONTHS].printResult(AM,nm, total);}
cout << "\n\n" << setw(61) << "Enter Name of Month (capitalize 1st letter): ";
cin >> month;
total = AM[MAXMONTHS].calcdays(AM, month);
AM[MAXMONTHS].printResult(AM, nm, total);
}//for
}//else
return 0;
}//main
//data load-----------------------------
void Month::Load(Month AM[])
//in:AM; out:none
{
for (int n = 0; n < 12; n++) {
infile >> AM[n].MonthNumber;
infile >>(AM[n].MonthName);
infile >>(AM[n].MonthAbrv);
infile >>(AM[n].MonthDays);
}//for
}//fx load
//calculate days 1-----------------------
int Month::calcdays(const Month AM[], int nm)
//in:AM, nm; out:none
{
int total=0;
int n = 0;
if (nm < 1 || nm > 12)
{
cout << "\n\n" << setw(33) << "<<Invalid Entry>>";
return 0;
}//if
else
{
while (AM[n].MonthNumber <= nm)
{
total += AM[n++].MonthDays;
}//while
return total;
}//else
}//fx calcdays 1
//calculate days 2--------------------------
int Month::calcdays(const Month AM[], char *month)
//in:AM, month; out:none
{
int total=0;
for (int i =0; i < MAXMONTHS; i++)
{
if ( strcmp(month[i], *month) == 0 )
{
cout << "\n\n" << setw(33) << "<<Invalid Entry>>";
return 0;
}
for (int n = 0; n < 12; n++)
{
total += AM[n].MonthDays;
if ( strcmp(month,AM[n].MonthName ) == 0)
break;
}//for
return total;
}
}//fx calcdays 2
void Month:: printResult(const Month AM[], int nm, int total)
//in:AM, nm; out:none
{
cout << "\n\n" << setw(63) << "The total days in the year up to and including "
<<AM[nm-1].MonthName<< " = "
<<total<<endl;
}//fx PrintResult