explanation needed on assigning a struct member to an another structure ...
Guys,
Code:
(slaveIdent*) (SPIBuff.data);
Could not able to figure out how i am able to assign a struct member to an another structure in the main function... can someone explain the above declaration in words....
Full code
Code:
#include <stdio.h>
#include <string.h> // for strcmp()
#include <stdbool.h> // C99 feature
typedef struct {
char neuron_id [15];
char id_string [15];
} slaveIdent;
typedef struct {
char transLen;
int transType;
char data[32];
} sSpiBuf;
/* The actual transaction buffer */
sSpiBuf SPIBuff;
int main(void)
{
(slaveIdent*) (SPIBuff.data);
return 0;
}
I stripped the code ... actually they are using such declaration in memcpy...as below
Code:
memcpy(((slaveIdent *)SPIBuff.data)->id_string,idstr,15);
Please shed some light....
Thanks n regards
max