A
anon.asdf
Hello!
In the following code-snippet, is it possible to initialize each
element of arr, with STRUCT_INIT?
struct mystruct {
int a;
char b;
};
#define STRUCT_INIT {5, 'a'}
#define LEN 3
struct mystruct arr[LEN] = \
{STRUCT_INIT};
/* does not work: only 1st element initialized as desired */
/*
I don not want to write
{STRUCT_INIT, STRUCT_INIT, STRUCT_INIT};
since LEN can change!
!!!!!!!!!
*/
..
..
Can this be done?
Thanks
-Albert
..
..
..
..
/****** test-program ******/
#define <stdio.h>
int main(void)
{
int i;
for (i = 0; i < LEN; i++)
printf("|%d|, |%c|\n", arr.a, arr.b);
return 0;
}
In the following code-snippet, is it possible to initialize each
element of arr, with STRUCT_INIT?
struct mystruct {
int a;
char b;
};
#define STRUCT_INIT {5, 'a'}
#define LEN 3
struct mystruct arr[LEN] = \
{STRUCT_INIT};
/* does not work: only 1st element initialized as desired */
/*
I don not want to write
{STRUCT_INIT, STRUCT_INIT, STRUCT_INIT};
since LEN can change!
!!!!!!!!!
*/
..
..
Can this be done?
Thanks
-Albert
..
..
..
..
/****** test-program ******/
#define <stdio.h>
int main(void)
{
int i;
for (i = 0; i < LEN; i++)
printf("|%d|, |%c|\n", arr.a, arr.b);
return 0;
}