Page 390 - Programming Microcontrollers in C
P. 390
The Monitor Program 375
Any encoding or decoding is done in the stor
age routines.
T. Van Sickle August 1, 2000 */
#include “phone.h”
Epro able;
main()
{
char name[ALEN];
char number[NLEN];
Epro *epro;
int c;
#ifndef DOS
inituart(); /* initialize the uart to 9600 b/s */
#endif
epro=&able;
reset(&epro);
FOREVER
{
c=getchar();
fflush(stdin); /* needed for the PowerC compiler */
switch(c)
{
case ‘n’: /* new entry */
puts(“Enter new number and name\n”);
get(number,NLEN);
get(name,ALEN);
saveit(name,number,&epro);
break;
case ‘a’: /* print the next entry */
printafter(&epro);
break;
case ‘s’: /* show all */
printout(&epro);