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

gets() and getchar()

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








gets() and getchar()
PostPosted: Mon Nov 08, 2004 9:19 am     Reply with quote

I could use getchar() get individual ASCII data from RS232, but I could not use gets() function. what is the matter, I used this for testing

send 'RB' from rs232

used

char b; b1[30];
b=getchar()
if(b=='R')
output_high(PIN_a2);


and

gets(b1);
b=b1[0];
if(b=='R')
output_high(PIN_a2);


first code works, second didi not?
Ttelmah
Guest







Re: gets() and getchar()
PostPosted: Mon Nov 08, 2004 9:29 am     Reply with quote

Anonymous wrote:
I could use getchar() get individual ASCII data from RS232, but I could not use gets() function. what is the matter, I used this for testing

send 'RB' from rs232

used

char b; b1[30];
b=getchar()
if(b=='R')
output_high(PIN_a2);


and

gets(b1);
b=b1[0];
if(b=='R')
output_high(PIN_a2);


first code works, second didi not?

Gets, requires a line feed to terminate the string. Hence you would have to send 'RB', and then an <enter>, before the gets version will work.

Best Wishes
Guest








PostPosted: Mon Nov 08, 2004 9:42 am     Reply with quote

Thank you Ttelmah, according to your suggestion, if I want to send several strings, like,
char a[10], b[10], c[10] from RS232
then
after send the a[10], I have to send a '\r' right? '\r\' is a return right?

and then afetr b[10] a '\r' afer c[10] a'\r' and then

I could use gets() like
char a1[10], b1[10],c1[10];
gets(a1);
gets(b1);
gets(c1);

to get the transfered data rght?

thank you.
Guest








PostPosted: Mon Nov 08, 2004 9:49 am     Reply with quote

what I meaning in the last one is for multiple strings receives.
krakatau



Joined: 19 Feb 2009
Posts: 9

View user's profile Send private message

PostPosted: Wed Apr 01, 2009 2:38 am     Reply with quote

THANKS A LOT GUYS. i was required it.
thanksssssss
maybe thanks sent very years later. Wink
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