- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <stddef.h>
#define INITARR(arr,...) \
do \
{ \
typedef struct {typeof(*arr) __tmp_arr[sizeof( (typeof(*arr)[]){__VA_ARGS__} ) / sizeof(*arr)];} __tmp_str; \
*((__tmp_str *)arr) = (__tmp_str){{__VA_ARGS__}}; \
} while(0)
int main(void)
{
uint8_t *test;
test = malloc (sizeof (uint8_t[10]));
INITARR(test,1,2,3,4,5,6,7,8,9,10);
for (size_t i = 0; i < 10; i++)
{
printf("%" PRIu8 ", ", test[i]);
}
return 0;
}
inho 25.07.2017 23:39 # 0
govnokod3r 26.07.2017 02:57 # +1
Antervis 26.07.2017 07:17 # 0
AnalPerOral 26.07.2017 05:00 # −1
roman-kashitsyn 26.07.2017 12:16 # +4
AnalPerOral 26.07.2017 21:38 # −1