Home Forums EasyTransfer Library Support Forum How do I access the array elements of an array within a structure

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #3203
    Anonymous
    Inactive

    I have set up two structures as per the code below.

    struct SEND_DATA_STRUCTURE {

    float humidity;

    float temperature;

    unsigned int ldr;

    unsigned int lux;

    unsigned int onTime[8];

    };

     

    struct RECEIVE_DATA_STRUCTURE {

    int boilerStatus;

    };

     

    SEND_DATA_STRUCTURE txData;                // give names to the groups of data

    RECEIVE_DATA_STRUCTURE rxData;

    in the code below initializing the array elements works OK.  However, the commented out line doesn’t work and causes a compiler error.

    txData.onTime[7] = 82;        This work OK.

    // txData.onTime[8]  = 12,22,32,42,52,62,72,82;           This causes an error.

    Can someone please tell me how, if it is possible to initialize all the array elements in one go.

    Also is it possible to use a FOR loop to step through the array elements to print them out for example.

    Any help would be greatly appreciated as I have searched the internet and cannot find the answers.

    Thanks

    Bob

     

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.