How do you initialize an array at compile time in c?

1 answer

Answer

1164729

2026-05-01 09:50

+ Follow

In C, you can initialize an array at compile time by specifying its elements within curly braces during declaration. For example, you can declare and initialize an integer array like this: int arr[] = {1, 2, 3, 4, 5};. The size of the array can be omitted, and the compiler will automatically deduce its size based on the number of elements provided. Additionally, you can specify the size explicitly, such as int arr[5] = {1, 2, 3, 4, 5};.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.