#C struct of an array syntax problem

13 messages · Page 1 of 1 (latest)

opaque osprey
#

hello everyone
I have a lit problem
can anyone help me with this issue
I respected the rules and tried googling this stuff, But no solution

typedef struct {
  unsigned int startTime;
  unsigned int endTime;
} Meeting;

Meeting T[5];

T[100] = [ {0, 1}, {3, 5}, {4, 8}, {10, 12}, {9, 10} ];
livid daggerBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

hot forge
#

?

#

you created an array of size 5

#

but you're assigning to index 100

opaque osprey
#

Well I fixed my code a lit bit,
but I'm still facing some new errors...

Meeting T[5];
T[] = {{0, 1}, {3, 5}, {4, 8}, {10, 12}, {9, 10}};

what about this one ?

hot forge
#

well now you're not assigning to any element..

#

you can move your definition line to declaration too

opaque osprey
#

I wanna assign the whole bunch of structs in one line what should I do without any functions for sure ...

hot forge
#
typedef struct {
  unsigned int startTime;
  unsigned int endTime;
} Meeting;

Meeting T[5]= {{0, 1}, {3, 5}, {4, 8}, {10, 12}, {9, 10}};
opaque osprey
#

Thanks for helping it works 🙂

livid daggerBOT
#

@opaque osprey Has your question been resolved? If so, run !solved :)

opaque osprey
#

!solved