This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Can`t assign a value in a struct field

Hello,

i have these struct.

typedef struct fila
{
int teste;
unsigned char data1;
unsigned char data2;
unsigned char data3;
unsigned char data4;
unsigned char data5;
struct fila *prox;
}Fila;

but i can`t put any value in the fields.

i tried this

msgs->data1=0x01;
msgs->data2 = 0x02;
msgs->data3 = 0x03;
msgs->data4 = 0x04;
msgs->data5 = 0x05;

but that doesn`t work

Anyone can help me? I`m using ccs v6

  • Hello Lucas,

    What does your program look like?  Are you passing address of the structure to a function?  Maybe if you post a small bit of the program, i.e. the function call and variable declaration.

    Stephen

  • Hi,

    I receive data from SPI and try to put it in these struct, but for test i trying to put values in these variable.

    Fila *msgs;

    i initialize this with

    msgs = criarFila;

    Fila *criarFila()
    {
    return NULL;
    }
  • criarFila() returns NULL. By assigning NULL to your msgs pointer (that's what the * means), you are basically ready to access the very beginning of your device's memory. 99.9% sure it is NOT a place to store anything.

    I recommend you to read some online documentation about pointers, and C code in general.

    Meanwhile, to have it work, do not declare a pointer and don't call criarFila().

    Fila msgs;
    msgs.data1 = 1;
    msgs.data2 = 2;

    and so on.


    Good luck!
  • Thank you, it work, i will read about it.