September 2001
Beginner
970 pages
23h 20m
English
| 1: | What's wrong with this program?
int main(void)
{
int * fp;
int k;
fp = fopen("gelatin");
for (k = 0; k < 30; k++)
fputs(fp, "Nanette eats gelatin.");
fclose("gelatin");
return 0;
}
|
| 2: | What would the following program do? (Macintosh users can assume the program correctly uses console.h and the ccommand() function.)
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
int ch;
FILE *fp;
if ( (fp = fopen(argv[1], "r")) == NULL)
exit(1);
while ( (ch= getc(fp)) != EOF )
if( isdigit(ch) )
putchar(ch);
fclose (fp);
return 0;
}
|
| 3: | Suppose you have these statements in a program:
#include <stdio.h>
FILE * fp1,* fp2;
char ch;
fp1 = fopen("terky", "r");
fp2 = fopen("jerky", "w");
Also, suppose ... |
Read now
Unlock full access