C: assigning values to arrays inside structures

Joined
Jun 10, 2008
Messages
1
Reaction score
0
hi all, my code may be inefficient (which is fine for me right now), but its also doing something wrong, in a nutshell, here it is:

> #include <stdio.h>
> #include <stdlib.h>
>
> struct Structure1{
> float weeks;
> } step[10];
>
> void main(){
> step[].weeks = {1,2,3,4,5,6,7,8,9};
> }

the compiler is having issues with the second to last line where i try to assign values to each array of the structure at once. is there any way to do this besides going through each index individually (ie, step[0].weeks = 1; step[1].weeks = 2;...)?

-Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top