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 support@ccsinfo.com

[SOLVED]easy question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

View user's profile Send private message Send e-mail

[SOLVED]easy question
PostPosted: Thu Sep 05, 2013 9:04 am     Reply with quote

Hi, excuse me for my stupidly question,
I have a problem when I want to write middle a line it delete other word,
i.e:
"hello CCS"
when I want add "my" between hello and CCS it delete "CC" and then add my:
instead of "hello my CCS" it wrote:
"hello myS"

best regards,


Last edited by asadi.siyavash@gmail.com on Thu Sep 05, 2013 12:48 pm; edited 1 time in total
hhockersmith



Joined: 07 Nov 2012
Posts: 6

View user's profile Send private message

PostPosted: Thu Sep 05, 2013 9:24 am     Reply with quote

CCS C uses a null terminated character array for strings. The array is created and then populated with the string. When you go to add to the middle of the array the array does not shift over automatically. Since it does not know how to shift it simply overwrites the characters in the array.

If you want to add to the middle of a string you would either need to create your own shift function or figure out a way to split the string apart and then rebuild it with your new word in the middle.

An example would be to take your "hello CCS" and add "my". First you need to expand the current array into a new larger array to make room for the new letters. To do this you would determine the length of the new word ("my" = 2 plus a space). Then create a new array with length = old array length+3. Then you need to copy each char over then skip and leave room for the new word, then copy the rest. Once you have the expanded array ("hello ---CCS") you can copy in the my and set the space ("hello my CCS").

Did that help?
_________________
*Sigh* How many times do I have to tell you managers I am not a miracle worker, I am one man.
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

View user's profile Send private message Send e-mail

PostPosted: Thu Sep 05, 2013 12:08 pm     Reply with quote

thank you for your reply but I think I describe my question very bad, my question was in CCS compiler, when I want to write stream between error & bit :
Code:
#use rs232(baud=9600,parity=N,xmit=PIN_C0,rcv=PIN_C1,bits=8,stream=PORT1,errors)

it wrote:
Code:
#use rs232(baud=9600,parity=N,xmit=PIN_C0,rcv=PIN_C1,bits=8,stream=PORT1
[/quote]
hhockersmith



Joined: 07 Nov 2012
Posts: 6

View user's profile Send private message

PostPosted: Thu Sep 05, 2013 12:40 pm     Reply with quote

Wait you mean you start with
Code:

#use rs232(baud=9600,parity=N,xmit=PIN_C0,rcv=PIN_C1,bits=8,errors)

and want to get to
Code:

#use rs232(baud=9600,parity=N,xmit=PIN_C0,rcv=PIN_C1,bits=8,stream=PORT1,errors)

but actually end up with
Code:

#use rs232(baud=9600,parity=N,xmit=PIN_C0,rcv=PIN_C1,bits=8,stream=PORT1


If so, check to make sure the editor is in "Insert" typing mode instead of "Overwrite". This is often toggled using the [Insert] key. Check on the status bar for that it should be towards the left side. I'm guessing that you accidentally got tripped into that mode. If that is not the case (or it is still in insert mode but doing the overwrite) we may need to look into something else.
_________________
*Sigh* How many times do I have to tell you managers I am not a miracle worker, I am one man.
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

View user's profile Send private message Send e-mail

PostPosted: Thu Sep 05, 2013 12:46 pm     Reply with quote

dear hhockersmith,
your answer is exactly true thank you alot,

Sincerely yours,
Siyavash.
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