C: assigning values to arrays inside structures

Discussion in 'C Programming' started by nflemming2004, Jun 10, 2008.

  1. nflemming2004

    nflemming2004

    Joined:
    Jun 10, 2008
    Messages:
    1
    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
    nflemming2004, Jun 10, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tweak
    Replies:
    14
    Views:
    2,761
    Eric Sosman
    Jun 11, 2004
  2. Alfonso Morra
    Replies:
    11
    Views:
    702
    Emmanuel Delahaye
    Sep 24, 2005
  3. emyl

    Assigning values to char arrays

    emyl, Nov 1, 2007, in forum: C Programming
    Replies:
    62
    Views:
    1,533
    Ben Bacarisse
    Nov 8, 2007
  4. Philipp
    Replies:
    21
    Views:
    1,103
    Philipp
    Jan 20, 2009
  5. weston
    Replies:
    1
    Views:
    238
    Richard Cornford
    Sep 22, 2006
Loading...

Share This Page