3. (4 points) What command would I type to print a list of files that have names ending in ".c" and that contain the string "<stdio.h>"?
4. (5 points) How can you delete a file named -i?
5. (8 points) How does the shell use the path variable (in C shell, path; in Bourne shell, PATH)?
6. (15 points) What does the following print? If the ANSI standard says that more than one output is possible, give them all and explain why more than one is possible.
int a = 0, b = 4, c = 5, d = -2, x; double dx;
#include <stdio.h>
int i = 3;
void g(int i)
{
printf("%d\n", i);
{
static int i = 0;
printf("%d\n", i++);
}
printf("%d\n", i);
}
void main(void)
{
g(i);
printf("%d\n", i + i);
{
register int i;
i = 5;
printf("%d\n", i);
}
printf("%d\n", i);
g(i);
}
9. (15 points) What is the value of n after the following code
executes?
char charray[] = "A-DF123";
int n = 0, s = 1;
char *p = charray;
while(*p){
switch(*p++){
case '-':
s = -s;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
n = n * 10 + (p[-1] - '0');
break;
}
}
n = s * n;
10. (15 points) In the following:
char line[1024]; char *p; if (fgets(p, 1024, stdin) != NULL) for(p = line; *p; p++) putchar(`A'<=*p && *p<=`Z' ? *p-`A'+`a' : *p);