Re: structure pointers




"raghu" <ragavakumar@xxxxxxxxx> wrote in message
news:1162192614.605043.263510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello

This is Raghu. I have a problem in the pointers.
The code is
typedef struct Tlv{
/*type Length value for each
message */
unsigned char ucType; /*Type varies from message to
message */
unsigned short usLength;/*Length */
unsigned int ucValue;/*Value*/
}tlv;


typedef struct te{
char d;
int e;
}Q;

struct temp{
int a;
unsigned int c;
Q *q;
tlv *T;
};

struct temp t;
t.a = 4;
t.c = 31;
t.q[0].d =21;
t.q[0].e = 23;
t.q[1].d = 11;
t.q[1].e = 4;

Another problem here. What is t.q?
You have not assigned q to point anywhere


t.T -> ucType = 1;
t.T -> usLength = 11;
t.T -> ucValue = 21;
printf("The entered values are ");
printf("%d\n%d\n", t.a, t.c);
printf(" %d \n", t.q[0].d);
printf(" %d \n",t.T->ucType);
return 0;
}
when I run this program some error is generating that is Segmentation
fault.
Can you please help me.
Thanks in advance.

-Bye
Raghu

--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project


.



Relevant Pages

  • structure pointers
    ... typedef struct Tlv{ ... unsigned char ucType; ...
    (comp.lang.c)
  • Re: structure pointers
    ... This is Raghu. ... typedef struct Tlv{ ... unsigned char ucType; ...
    (comp.lang.c)
  • Re: bug in checkpath.pl
    ... (struct mrvlietypes_ratesparamset *) ... if (*tlv == 0) ... the latest development snapshot. ...
    (Linux-Kernel)
  • bug in checkpath.pl
    ... I have a case where scripts/checkpatch.pl returns a false error. ... (struct mrvlietypes_ratesparamset *) ... if (*tlv == 0) ...
    (Linux-Kernel)