An array stores multiple values of the same data type. For an array, there may be situations where the same 2-3 values need to be stored, that is, 3,3,3,3 need to be stored.
For this situation, the programming language C provides a simple way to create an array containing such repeated values to reduce the programmer's workload.
[startofRepeatingSeq … EndofRepeatingSeq]number Example : For 3 repeated 5 times ; [0 … 4]3
#include <stdio.h> int main() { int array[10] = {[0 ... 4]3, [6 ... 9]5}; for (int i = 0; i < 10; i++) printf("%d ", array[i]); return 0; }
3 3 3 3 3 0 5 5 5 5
The above is the detailed content of Is there a shorthand array notation for repeated values in C?. For more information, please follow other related articles on the PHP Chinese website!