CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Feb 2019
    Posts
    2

    error: invalid types ‘unsigned int[unsigned int]’ for array subscript

    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;
            }
    }
    Last edited by VictorN; February 11th, 2019 at 01:56 PM. Reason: Added code tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured