C
Carramba
Hi!
I have a big struct and I want to initialize it at once, but I get parse
error before "{" compiler error. can't it by done?
#include <stdio.h>
#include <stdlib.h>
typedef struct{
int b;
int c;
int d;
int e;
}A;
A *a;
int main(void) {
a = malloc(4 * sizeof (*a));
a = {1,1,4,5}; //there is error from my compiler
printf("%d ; %d\n", a->b+a->d, a->c*a->e);
free(a);
return 0;
}
is this is bad way to init struct how one should do?
I have a big struct and I want to initialize it at once, but I get parse
error before "{" compiler error. can't it by done?
#include <stdio.h>
#include <stdlib.h>
typedef struct{
int b;
int c;
int d;
int e;
}A;
A *a;
int main(void) {
a = malloc(4 * sizeof (*a));
a = {1,1,4,5}; //there is error from my compiler
printf("%d ; %d\n", a->b+a->d, a->c*a->e);
free(a);
return 0;
}
is this is bad way to init struct how one should do?