Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Copy the structure variable to a string

1 view
Skip to first unread message

mkeles84

unread,
Jul 22, 2008, 1:03:09 AM7/22/08
to
---------------
struct exam{
char name[5];
char surname[7];
int point;
.....
.....
}example;
char line[60];
strcpy(example.name,"adem");
strcpy(example.surname,"mehmet");
point=2343;
strcpy(line,(char*)&example);
printf("%s",line);
----------------
How can I do that copy a structure to a string? The result must be "adem
mehmet 2343"
but I saw on screen: "adem"

--
Message posted using http://www.talkaboutcomputing.com/group/comp.std.c/
More information at http://www.talkaboutcomputing.com/faq.html

Keith Thompson

unread,
Jul 22, 2008, 3:02:25 AM7/22/08
to
"mkeles84" <mkel...@hotmail.com> writes:
> ---------------
> struct exam{
> char name[5];
> char surname[7];
> int point;
> .....
> .....
> }example;
> char line[60];
> strcpy(example.name,"adem");
> strcpy(example.surname,"mehmet");
> point=2343;
> strcpy(line,(char*)&example);
> printf("%s",line);
> ----------------
> How can I do that copy a structure to a string? The result must be "adem
> mehmet 2343"
> but I saw on screen: "adem"

You've posted to the wrong newsgroup again. Your question is
appropriate in comp.lang.c, not comp.std.c. Please re-post it there.

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

0 new messages