Getting Started

(lily) #1

Chapter 6: C Functions and Program Structures


&& (s[2] == 'm') && (s[3] == 'm') )
// parse the fifth character

Comm1(s);

);
k;
case 'd':

default:
sent: '");

'd':
) && (s[2] == 'm') && (s[3] == 'o') && (s[4] == '?') )
g to the PC_Comm demo.\r");
case 'h':
[1] == 'e') && (s[2] == 'l') && (s[3] == 'l') && (s[4] == 'o') )

String("\rYou sent: '");
sendChar(s[0]);
sendString("' - I don't understand.\r");
break;

1(char s[])
onder(s,s[4]);

responder(s,s[4]);


{
// parse first character
switch (s[0])
{
case 'c':
if( (s[1] == 'o')
switch (s[4])
{
case 'a':


break;
case 'b':
Comm2(s);
break;
case 'c':
Comm3(s
brea


Comm4(s);
break;


sendString("\rYou
sendChar(s[0]);
sendString("' - I don't understand.\r");
}
break;
case
if( (s[1] == 'e'
sendString("You are talkin
break;


if( (s
sendString("Hello yourself\r");
break;
default:
send


}
s[0] = '\0';
}


void Comm
{
resp
}


void Comm2(char s[])
{

Free download pdf