If buff is not an array of bytes, you can initialize it only with values that consist of repeating hexadecimal values using memset (e.g. -1, 0x01010101, etc.)
One way to do this is to use memcpyit this way:
buff[0] = 5;
memcpy(buff + 1, buff, sizeof(buff) - sizeof(*buff))
HOWEVER , it depends on undefined behavior and may or may not work on your system.
A decent compiler should create a fairly efficient loop from
for (i = 0; i < 1000; i++) buff[i] = 5;
source
share