im having trouble passing my string. here is the code
void main()
{
int day;
int month;
int year;
char dayOfWeek[10] = {'\0'};
DateToDay thisDay;
cout << "Enter the Month as a number: ";
cin >> month;
cout << "Enter the Day as a number: ";
cin >> day;
cout << "Enter the Year as a number: ";
cin >> year;
thisDay.getDay(day, month, year, dayOfWeek);
cout << month << "/" << day << "/" << year << " falls on a " << dayOfWeek << endl;
}
void DateToDay::getDay(int day, int month, int year, char theDay[])
{
int century;
int numberInWeek; //the number returned by the formula
char *daysOfWeek[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
century = year / 100;
year = year % 100;
numberInWeek = (day + 25 * (month + 1) / 10 + year + year / 4 + century / 4 + 5 * century) % 7;
theDay = daysOfWeek[numberInWeek];
}
i can print out theDay from inside the function, but the array in the calling function, dayOfWeek, that was passed from main(), remains all nulls
void main()
{
int day;
int month;
int year;
char dayOfWeek[10] = {'\0'};
DateToDay thisDay;
cout << "Enter the Month as a number: ";
cin >> month;
cout << "Enter the Day as a number: ";
cin >> day;
cout << "Enter the Year as a number: ";
cin >> year;
thisDay.getDay(day, month, year, dayOfWeek);
cout << month << "/" << day << "/" << year << " falls on a " << dayOfWeek << endl;
}
void DateToDay::getDay(int day, int month, int year, char theDay[])
{
int century;
int numberInWeek; //the number returned by the formula
char *daysOfWeek[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
century = year / 100;
year = year % 100;
numberInWeek = (day + 25 * (month + 1) / 10 + year + year / 4 + century / 4 + 5 * century) % 7;
theDay = daysOfWeek[numberInWeek];
}
i can print out theDay from inside the function, but the array in the calling function, dayOfWeek, that was passed from main(), remains all nulls