There is a header file named 'AAA.h'. In this header file we have define a structure called lrd
, which looks like:
struct lrd
{
int tc;
char ptc[5];
char stc[5];
char ath[5];
int vc;
};
struct lrd lr;
This header file 'AAA.h' is included in two different files name 'BBB.c' and 'CCC.c'. We have assigned the values for structure variable lr
in the 'BBB.c' file as following:
lr.tc=tc;
memcpy(lr.ptc,ptc,sizeof(ptc));
memcpy(lr.stc,stc,sizeof(stc));
memcpy(lr.ath,ath,sizeof(ath));
lr.vc=vc;
Above source variables take the value from database. And we use structure variable lr
in the 'CCC.c' file. We are using structure lrd variable as follows:
char *ptc()
{
sprintf(str, "lr.ptc(%s)", lr.ptc);
trace(str);
return lr.ptc;
}
char *stc()
{
sprintf(str, "lr.stc(%s)", lr.stc);
trace(str);
return lr.stc;
}
Variable stc gives the wrong value in the 'CCC.c' file. Please help me to figure it out.