I am trying to declare this array of strings(or a 2d character array,i reckon) in c language but the compiler ide is giving me error: "[Error] array type has incomplete element type"
char division[][]={"Northeast Division","Northwest Division","Southeast Division","Southwest Division"};
what am I doing wrong?
- 
 1Possible duplicate of 2D array initialisation in Cx-6-2-5– x-6-2-52018年10月20日 08:28:52 +00:00Commented Oct 20, 2018 at 8:28
- 
 Do you want to be able to modify those "string"s during run-time?alk– alk2018年10月20日 08:46:03 +00:00Commented Oct 20, 2018 at 8:46
2 Answers 2
You have to specify the maximum length of a string. This should solve your problem
char division[][25]={"Northeast Division","Northwest Division","Southeast Division","Southwest Division"};
 answered Oct 20, 2018 at 8:46
 
 
 
 arjunkhera 
 
 9677 silver badges25 bronze badges
 
 
 Sign up to request clarification or add additional context in comments.
 
 
 
 2 Comments
piku_baba
 in 1d array you dont need to do that if you given whats in the array...so why do you need to do that in 2d?
  arjunkhera
 because if we do not specify the row length, then the compiler will have no way of knowing how to deference other row elements. Check this and this for an in depth explanation.
  You can declare like this :
char *division[]={"Northeast Division","Northwest Division","Southeast Division","Southwest Division"};
Comments
Explore related questions
See similar questions with these tags.
lang-c