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

getc array send only one character

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







getc array send only one character
PostPosted: Mon Dec 03, 2007 6:29 am     Reply with quote

when use getc function to array , with using putc ,specific array index sholud be send to the pc

for example
from pc : send 12345 to pic 16f877a
pic: read array ,getc, then send it for example second data,2, w
how???

c[]=getc;//read 12345
putc(c[1]);//send only 2

but how ??
this is not true
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Dec 03, 2007 8:41 am     Reply with quote

I don't really understand your question, but this may help.

getc() and putc() normally only handle one byte, or character at a time. An odd addition to standard C in CCS is that if you give putc() a multi-byte argument the compiler calls putc() once for each byte. This can not work with getc() as the compiler has no way to know how many bytes are out there.

Maybe you should use string functions instead of byte (character) functions?
_________________
The search for better is endless. Instead simply find very good and get the job done.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 03, 2007 2:11 pm     Reply with quote

Look at the get_string() function, to get a string. It's in this CCS file:
Quote:
c:\Program Files\picc\Drivers\Input.c


Also look at the puts() function, to send a string.
Storic



Joined: 03 Dec 2005
Posts: 182
Location: Australia SA

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

Re: getc array send only one character
PostPosted: Mon Dec 03, 2007 2:32 pm     Reply with quote

saee wrote:

c[]=getc;//read 12345
putc(c[1]);//send only 2


putc(c[0]);//will send 1

when I was first learning C, I got confused with the fact C uses '0' as a valid count.
Code:

for(i=0; i<=4; i++)
   putc(c[i]);

should give you 12345 c[0],c[1],c[2],c[3],c[4],
_________________
What has been learnt if you make the same mistake? Wink
yesahycs



Joined: 31 Oct 2007
Posts: 5

View user's profile Send private message

dun use putc
PostPosted: Wed Dec 05, 2007 3:47 am     Reply with quote

try printf instead of putc.
ex:

int i;

for(i=0; i<=4; i++)


printf("%d",c[i]);
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