Simple one line stopping code from compiling, what is wrong?
char *words[256] = new char[numOfWords][256];
array must be initialized with a brace-enclosed initializer
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You declared an array of 256 pointers to
char. The error message is clear – arrays need to be initialized with a brace-enclosed initializer. So if you want to keep your declaration, do this:Alternatively, you can leave out the initialization altogether and assign individual elements later, say in a loop. Note that, if you allocate elements dynamically, you’re also responsible for deleting them properly.
If you want a pointer to an array of arrays of 256
chars, then this: