Omitting Array Size During Initialization
When initializing an array upon declaration, you can omit the size. The compiler will automatically determine the size based on the number of elements provided.
Example: Omitting Array Size
char vowels[] = {'a', 'e', 'i', 'o', 'u'};
Key Takeaways
- Omitting the size is acceptable when initializing the array immediately.
- The array size is inferred from the number of elements.
- Helps prevent mismatches between declared size and actual number of elements.