0

Hi,
I've not worked in C, C++ from like 5-6 years.
But now I got to do a very small change (explained below).
I tried reading tutorials but only got confused.

Below I've struct containing 2 attributes.
I need to create its refrence and pass values to these 2 attributtes.

File in which struct is defined.

//List of includes

typedef struct dscvs {
    UPD_TRC(trc_no);
    UPD_STS(status);
}dscvs_i;

File in which struct variable is used
// Here I need to create a variable of type dscvs_i, so that I can feed the values inside UPD_TRC(trc_no) & UPD_STS(status);
// This is what I'm doing

dscvs_i *i_updsc;
i_updsc->trc_no = trcno;

But this is throwing error "error: expression must be a modifiable lvalue"

Please suggest.

Edited by raul8

2
Contributors
1
Reply
4
Views
4 Years
Discussion Span
Last Post by rajenpandit
0

Hi,

I think the structure defination is wrong; It should be like

` //asumng UPD_TRC and UPD_STS is user defined data type.`

    typedef struct dscvs {
        UPD_TRC trc_no;
        UPD_STS status;
    }dscvs_i;

    dscvs_i *i_updsc;

    // point i_updsc to some memory location before using it.
    i_updsc=new dscvs_i;
    i_updsc->trc_no = trcno;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.