Portability Issues 821
D
Workshop
The Workshop provides quiz questions to help you solidify your understanding of the
material covered and exercises to provide you with experience in using what you’ve
learned.
Quiz
- Which is more important: efficiency or maintainability?
- What is the numeric value of the letter a?
- What is guaranteed to be the largest unsigned character value on your system?
- What does ANSI stand for?
- Are the following variable names valid in the same C program?
int lastname,
LASTNAME,
LastName,
Lastname; - What does isalpha()do?
- What does isdigit()do?
- Why would you want to use functions such as isalpha()andisdigit()?
- Can structures be written to disk without worrying about portability?
- Can TIMEbe used in a printf()statement to print the current time in a pro-
gram? Here’s an example:
printf( “The Current Time is: %s”, TIME );
Exercises
1.BUG BUSTER:What, if anything, is wrong with the following function?
void Print_error( char *msg )
{
static int ctr = 0,
CTR = 0;
printf(“\n” );
for( ctr = 0; ctr < 60; ctr++ )
{
printf(“*”);
}
printf( “\nError %d, %s - %d: %s.\n”, CTR,
__FILE__, __LINE__, msg );
for( ctr = 0; ctr < 60; ctr++ )
{
47 448201x-APP D 8/13/02 11:17 AM Page 821