C - How to initialize a range of elements to the same value? Code Example

The code for How to initialize a range of elements to the same value?

// To initialize a range of elements to the same value, 
// write `[first ... last] = value'. 
// This is a GNU extension. For example,

int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };
Code by IncludeHelp, on August 11, 2022 16:17
Reference: 5.20 Designated Initializers

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.