CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

strcpy(union,string)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Richard Slater



Joined: 08 Sep 2003
Posts: 12
Location: Cambridge, UK

View user's profile Send private message Visit poster's website

strcpy(union,string)
PostPosted: Thu Feb 27, 2003 7:13 am     Reply with quote

Hello people

I am tring to copy a string to a union member using the following format:

strcpy(Command_Result.String_Value,Disp_Msg);

where

pre
union Command_Result_Value{
int U_Int_Value;
int Error_Value;
signed int S_Int_Value;
long U_Long_Value;
signed long S_Long_Value;
char String_Value[9];
}Command_Result;


char Disp_Msg[Disp_Size+1];

When I do printf("\%s\n\r",Command_Result.String_Value) it prints a nothing for the \%s and then the \n\r, so all you see is a blank line.

If I do :
strcpy(Command_Result.String_Value,"Hello World");
it prints "Hello World" as expected.

Is it not possible to copy a string variable to a union member?

Thanks in advance

Richard

ps. I have used 'pre' and '/pre' to try and keep the indentation in the code, if this has not worked could some kind soul please tell me how to do it?!
/pre
___________________________
This message was ported from CCS's old forum
Original Post ID: 12166
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: strcpy(union,string)
PostPosted: Thu Feb 27, 2003 8:51 am     Reply with quote

:=Hello people
:=
:=I am tring to copy a string to a union member using the following format:
:=
:=strcpy(Command_Result.String_Value,Disp_Msg);

Try including the "string.h" file, which is in the
c:\Program Files\Picc\Drivers folder, and use the
"strcopy" function instead. Note that it's spelled
differently than "strcpy".


:=
:=where
:=
:=pre
:=union Command_Result_Value{
:= int U_Int_Value;
:= int Error_Value;
:= signed int S_Int_Value;
:= long U_Long_Value;
:= signed long S_Long_Value;
:= char String_Value[9];
:=}Command_Result;
:=
:=
:=char Disp_Msg[Disp_Size+1];
:=
:=When I do printf("\%s\n\r",Command_Result.String_Value) it prints a nothing for the \%s and then the \n\r, so all you see is a blank line.
:=
:=If I do :
:=strcpy(Command_Result.String_Value,"Hello World");
:=it prints "Hello World" as expected.
:=
:=Is it not possible to copy a string variable to a union member?
:=
:=Thanks in advance
:=
:=Richard
:=
:=ps. I have used 'pre' and '/pre' to try and keep the indentation in the code, if this has not worked could some kind soul please tell me how to do it?!
:=/pre

That's because you have surround html tags with angle-brackets.
See the following two links for an example.
<a href="http://www.createafreewebsite.net/html_tutorial/pre_tag.html" TARGET="_blank">http://www.createafreewebsite.net/html_tutorial/pre_tag.html</a>
<a href="http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_pre" TARGET="_blank">http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_pre</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12168
sar



Joined: 08 Sep 2003
Posts: 36

View user's profile Send private message

Re: strcpy(union,string)
PostPosted: Thu Feb 27, 2003 2:58 pm     Reply with quote

Hello Richard
Did you ever write any code for those HDSP 2xxx displays. If so do you have examples? I'm trying to interface and write to DS1307 RTC. SAR
___________________________
This message was ported from CCS's old forum
Original Post ID: 12181
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group