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

getch() problem

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



Joined: 20 Feb 2010
Posts: 1

View user's profile Send private message

getch() problem
PostPosted: Sat Feb 20, 2010 4:38 am     Reply with quote

Here is the code I am trying to compile:
Code:

char menu(void);

void main()
{
   while(1)
   {
    switch (menu()) {

      case '1': {
         output_bit(PIN_A0,1);
         delay_ms(1000);   
         output_bit(PIN_A0,0);
         break;
        }
 
      case '2': {
         output_bit(PIN_A1,1);
         delay_ms(1000);   
         output_bit(PIN_A1,0);
         break;
        }

      case '3': {
         output_bit(PIN_A2,1);
         delay_ms(1000);
         output_bit(PIN_A2,0);
         break;
        }

      default: {
         output_bit(PIN_A0,0);
         output_bit(PIN_A1,0);
         output_bit(PIN_A2,0);   
         break;
        }
    }
}

///////User Selection Menu//////////////////////////////
line 54: char menu(void)
{
char ch;

printf ("\n\r Press A to turn LED on RA0 .......");
printf ("\n\r Press B to turn LED on RA1 .......");
printf ("\n\r Press C to turn LED on RA2 .......");

ch = getc();   //wait for and get serial character   
//delay_ms(100);
return ch;
}
/////////////////////////////////////////////////////////

And these are the error messages I am getting:
Quote:

>>> Warning 203 "pic18f4523ledo_p.c" Line 13(1,1): Condition always TRUE
*** Error 51 "pic18f4523ledo_p.c" Line 54(1,5): A numeric expression must appear here
*** Error 127 "pic18f4523ledo_p.c" Line 62(10,16): Return value not allowed in void function
*** Error 79 "pic18f4523ledo_p.c" Line 66(57,58): Expect }
3 Errors, 1 Warnings.

I am lost. What am I missing here?
Ttelmah
Guest







PostPosted: Sat Feb 20, 2010 2:12 pm     Reply with quote

Start by getting rid of the brackets round the case sections....

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Feb 20, 2010 4:40 pm     Reply with quote

In addition to that, I think you're missing a closing brace at the end of main().
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