Scott Rose

Switch Command

Discussion created by Scott Rose on Apr 2, 2008
Latest reply on Apr 2, 2008 by Scott Rose
Hi,
 
I am new to embedded software programming and using Codewarrior.I have done some c++ and turbo c programming before.
 
I am trying to program the mc9s12e128 chip.
 
The first question i have is regarding the switch statement.See below.
 
switch(rx_msg[0])
{
 case ('h'):sendmessage(tx_msg_1):break;
 case ('s'):sendmessage(tx_msg_2):break;
 default:sendmessage(tx_msg_3);
}
 
Is this the correct syntax for the switch statement which does complie ? 
 
Normally if using C builder for a console program i would use:     case 'h':sendmessage(    ):break;
But this format does not compile thats why i added the brackets : case ('h'):....  and it now it compiles.
 
Also is the correct include file for the switch statement : #include <stdlib.h> ?
Where would i find information regarding which include file is needed for certain commands ?
 
Can anyone help ?
 
Thanks,
 
Scotty5555

Outcomes