In the exercise about
getfeedback,I initialised an array
feedback of the
type feedback. However, if I try to initialise a value into my array with
I get this error message
expression must be a pointer to a complete object typeC/C++(852)
Is that not how you assign value to an array of enum data type with index i?
Yes, it is the correct way.
Why is your array of type
feedback, isn’t the defined enum
feedback_result? And shouldn’t it be
Have you made sure that your
feedback array has the correct type?
Have you included
wordle.h, where the enum is declared?
Yes, the feedback array has been defined as
enum feedback_result* feedback and used malloc to allocate memory for it.
I forgot to put the pointers in the previous post. I’ve included
wordle.h as well and have no issues with declaring
If I declare feedback as
enum feedback_result** feedback, the assignment
feedback[i]=WRONG works. However, without it, I keep getting the same error message.
feedback_result* feedback =...
Should work, I can’t tell why it is not working for you. Maybe, you can come to an Office Hour?
The enum type is defined as
Therefore you should not write
enum in front of using it:
// no "enum" here
feedback_result *getFeedback(char *guess, char *word1, char *word2, int k);
// no "enum" here either
feedback_result *feedback = ...
When you write
enum, C assumes that you want to declare a new type, unless an enum of that name (without typedef) has been declared before.
This new type is never finished. Hence the error speaking of a
complete object type.