Download Practical C Programming - International Research Institute MICA

Transcript
Answers
343
portable is not easy. Still, if you keep portability in mind when creating the code,
you can minimize the problems.
Answers
Answer 20-1: The variable zip is a long int. The printf specification %d is for a
normal int, not a long int. The correct specification is %ld to indicate a long:
printf("Zip code %ld\n", zip);
Answer 20-2: The problem is that C uses the backslash (\) as an escape character.
The character \r is a carriage return, \n is newline, and \t is a tab. What we
really have for a name is:
<return>oot<newline>ew<tab>able
The name should be specified as:
const char NAME[] = "\\root\\new\\table";
NOTE
The #include uses a filename, not a C string. While you must use
double backslashes (\\) in a C string, in an #include file, you use
single backslashes (\). The following two lines are both correct:
const char NAME[] = "\\root\\new\\table";
#include "\root\new\defs.h"