Mar 12, 2019 at 3:37pm UTC
when I try to run the program, in lines 24 and 53 are giving me a binary error. If Anyone can help ASAP, greatly appreciated.
#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;
int isleap(int year){
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
return 1;
return 0;
}
void printCalendar(int year,int starting_day,string filename)
{
ofstream out;
out.open(filename.c_str());
if(!out){
cout<<"File doesn't open \n";
return ;
}
out<<"\t\tCalendar - "<<year<<"\n\n";
int month_day[]={31,28,31,30,31,30,31,31,30,31,30,31};
string months[] = {"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"
};
month_day[1]+=isleap(year);
for (int i = 0; i < 12; i++)
{
int days = month_day[i];
// Print the current month name
out<<"\n ------------"<<months[i]<<"-------------\n";
// Print the columns
out<<" Sun Mon Tue Wed Thu Fri Sat\n";
// Print appropriate spaces
int k;
for ( k = 0; k < starting_day; k++)
out<<" ";
for (int j = 1; j <= days; j++)
{
out<<setw(5)<<j;
if (++k > 6)
{
k = 0;
out<<"\n";
}
}
if (k)
cout<<"\n";
starting_day = k;
}
return;
}
int main()
{
int year ;
int starting_day;
string filename;
cout<<"Enter Year : ";
cin>>year;
cout<<"Enter starting day : ";
cin>>starting_day;
cout<<"Enter Output filename : ";
cin>>filename;
printCalendar(year,starting_day,filename);
return (0);
}
Mar 12, 2019 at 3:54pm UTC
Why don't you enclose your code with code-tags? Expect you that we count your claimed line-nos by counting down all lines with our fingers?