I want to define a struct
to emulate a vector, containing an array of double vec
and an integer N
representing how many entries are valid.
I want to set all the entries of the array to be zero before filling N of them with non zero values. I tried this code:
typedef struct {
int N;
double vec[1000];
} Vector ;
int main()
{
int N1;
double vec1[1000] = { 0 };
Vector vector;
vector.vec = { 0 };
return 0;
}
The compiler accepts the initialization of vec1
, but not of vector.vec
. I get an error that says:
so.c:11:16: error: expected expression
vector.vec = { 0 };
^
1 error generated.
What am I doing wrong?