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() Problem

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



Joined: 20 May 2014
Posts: 5

View user's profile Send private message

gets() Problem
PostPosted: Sun Jun 01, 2014 7:38 pm     Reply with quote

hi I am trying to prepare a program controlled by a virtual terminal. Then I have a problem with the function gets (string) it blocks in the while loop. I want to know how to execute the same program if I did not write the letter R is disigne as loop interruption
Code:

while(true)
{
 gets(string);
  if(!strcmp(string,retour)){  // blocked  here
     goto start;
 }

if(a==1)
{
    output_low(pin_d0);
    output_high(pin_d1);
    s=1;
  }

if(b==1)
{

    output_high(pin_d0);
    output_low(pin_d1);

  }
   if((input(pin_a0)==1)&&((b==1)||(s==1))){
    c=5;
  output_high(pin_D2);
   delay_us(1000);
  output_low(pin_D2);
   delay_us(60);
 
   

  for(i=0;i<c;i++)
  {
 
  output_high(pin_D2);
  delay_us(60);
  output_low(pin_D2);
   delay_us(60);}
 
   }
  else
  {output_low(pin_D2);
  }

}


 
}
this is a part of program if i delete the gets(string); the program was running normally Rolling Eyes
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Mon Jun 02, 2014 1:36 am     Reply with quote

Of course is sticks at gets(string).
Read the manual, it sits there waiting for a CR.

You get round the problem by polling kbhit() or use an isr.

Mike
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