QQ schrieb:
> Hi Here is part of my code
>
> typedef struct{
> int len;
> char code[16];
> }Code;
>
> typedef struct{
> ...
> Code *a;
> ...
> }List;
>
> Now I'd like to print the content.
>
> I have
>
> Code tmpA;
> List list;
> tmpA=5;
> memcpy(code,"12345",5);
> list.a = &tmpA;
> printf("a(len=%d,value=(%s))\n",list.a->len,list.a->code);
>
> however it seems that something wrong, the print out is not right.
What does it print? Does it print "42"? Then it would be right, it's the
answer.
Well, post compileable code and say _what_ is wrong, what you expected
and what you got instead.
However, you print list.a->code as it where a c-style-string
(null-terminated), but it actually isn't null-terminated, isn't it?
--
Thomas