cpp:20:1: error: too many initializers for ‘const char* [7]’ };

 I was getting this error, and this is the most simplest one I would say. 

Are you able to find what is wrong in the below program? 

1
2
3
4
5
6
7
8
9
10
11
12
13
#define MAX_DAY 6

const char *days[MAX_DAY + 1] = 
{
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Invalid"
};
The array days size is just 7, but I initialized with 8 elements. After popping out the last one,
it started working. Click here to understand the program.  

Comments