Cpp plus 1
Cpp plus 1

Reputation: 1010

Way to declare float compile-time constant in C

I know that I can declare a named compile-time constant in C for integers by using enums, but is there a way to declare named compile-time constants in C for floats as well, without using macros (I know that C++ has constexpr, but I am strictly using C right now)? Answers containing compiler-specific C-language extensions are also greatly appreciated.

Upvotes: 1

Views: 396

Answers (1)

Prince
Prince

Reputation: 21

Use array of const float. Which will produce constant data of type float. const float *arr[3] = {11.21,21.31,31.23}

Upvotes: -1

Related Questions