Hi salem, Thank you for the response.... can you please shed some more light.. still i got few questions....
Q1)
if this the case
Code:
typedef struct {
char transLen;
int transType;
// char data[32];
slaveIdent data;
} sSpiBuf;
then why doesnt this work printf("content : %s",SPIBuff.data->neuron_id); what i mean is that i am not able to print individual members .
q2)
what i understood from this (slaveIdent *) is that the data stored in SPIBuff.data is pointed by some random slaveIdent pointer..... is it so..??
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)
{
char nd[15] = "jack as a cat";
char idstr[15] = "sky is blue";
memcpy(((slaveIdent *)SPIBuff.data)->neuron_id,nd, 15);
memcpy(((slaveIdent *)SPIBuff.data)->id_string,idstr, 15);
printf("content : %s",SPIBuff.data);
return 0;
}