I have Tondo and Gimpel. There are a couple of aspects of their
answer that puzzles me.
The Question is to modify a sort program to handle a -r flag
( function is irrelevant), which needs to wrok together with a -n flag
( function again irrelevant..I believe).
Firstly, a very brief outline of the function.
......numerous function declarations;
#define NUMERIC 1
static char option = 0;
main (int argc, char *argv[])
{
.....snip....
while ( --argc 0 && (*++argv)[0] == '-')
...snip...
switch (c){
case 'n':
option |= NUMERIC;
....snip...
}
My first question relates to the use of the qualifyer "static";
My understanding ( or lack of) is that a static variable outside of a
function limits the scope of that variable to that file. Is this just
good programming by T&G or is there another good reason for this?
Secondly, is this use of bitwise operators commonly used to set and
get flags in a program in C?
Thanks in advance.