Louis I. answered 06/04/19
Computer Science Instructor/Tutor: Real World and Academia Experienced
Yes, there's a syntax for initializing C/C++ array [simple type] elements with like values in a declaration, and a way to re-assign like values at any point in runtime ... See simple test program below, and its output:
#include <stdio.h>
#include <string.h>
#define SIZE 512
int main() {
char array[SIZE] = { [ 0 ... SIZE-1 ] = 65 }; // assign 'A' to all 512 elements
// display some random elements
printf("%c\n", array[0]);
printf("%c\n", array[50]);
printf("%c\n", array[500]);
memset(array, 66, SIZE); // assign 'B' to all 512 elements
// display some random elements
printf("%c\n", array[0]);
printf("%c\n", array[50]);
printf("%c\n", array[500]);
}
OUTPUT
A
A
A
B
B
B