Why am I getting invalid type on
Project1.cpp:139:32: error: invalid types ‘unsigned int[unsigned int]’ for array subscript
os << Mon[month(date)-1];
Code:void displayDate(const Date& date, ostream& os, DATE_STYLE ds) { // if ds == MM_DD_YYYY) if (!wellFormed(date)) { cout << "Date Error\n"; exit(1); } else if (ds == MM_DD_YYYY) { if (numDigits(date) == 7) os << '0'; os << month(date) << '/'; if (nthDigit(date, 5) == 0) os << '0'; os << day(date) << '/'; unsigned y = year(date); unsigned len = 4 - numDigits(y); for (unsigned i = 0; i < len; ++i) os << '0'; os << year(date) << endl; } else string Mon[12] = {"Jan ", "Feb ", "Mar ", "Apr ", "May ", "June ", "Jul ", "Aug ", "Sept ", "Oct ", "Nov ", "Dec " }; unsigned Mon; os << Mon[month(date)-1]; if (nthDigit(date, 5) == 0) os << '0'; os << day(date) << ","; unsigned y = year(date); unsigned len = 4 - numDigits(y); for (unsigned i = 0; i < len; ++i) { os << '0'; os << year(date) << endl; } }




Reply With Quote
