|
|
CS 216
Review for First Quiz
- A character string is a ___ array terminated by ___.
- char, \n
- int, \0
- char, \0
- int, \n
- Which one of the following initializes a string array?
- char name[] = "ABC";
- char name[] = {'A', 'B', 'C'};
- char name[] = {ABC};
- char name[] = {'A', 'B', 'C', \0 };
- What is the chief difference between these two
statements?
static char heart[] = "I love Vanillie!";
char *head = "I love Millie!";
- head is a constant
- heart is a variable
- head is a variable
- heart is undefined
- Explain what happens, given the following code:
static char *mesg = "Don't be a fool!";
static char *copy;
copy = mesg;
- The string defined in mesg will be assigned to copy.
- The address mesg points to will be assigned to copy.
- The value of mesg will be assigned to copy.
- A compiler error will occur.
- The following function header indicates that
gets() returns a ___.
char * gets(char * s)
- string constant
- character constant
- pointer to char
- pointer to a pointer
- What is NULL in the following statement?
while(gets(name) != NULL)
continue;
- The NULL character
- Zero
- 1
- An address
- The scanf() function is more of a ___ function.
- get string
- get word
- get until NULL pointer
- get until newline
- Compared to scanf(), gets() has all of the
following advantages except which one?
- easier to use
- faster
- best for one word
- more compact
- What argument type is required by the
puts() function?
- a variable name
- a string address
- a string constant
- Both a and c are correct.
- Which of the following means the same as
the statement:
printf(" %s\n", string);
- puts(*string);
- puts("string");
- puts(\nstring);
- puts(string);
- Which string function adds a copy of the second
string to the end of the first, to form a new,
combined string?
- strlen()
- strcat()
- strcpy()
- strcmp()
- Which header file contains function prototypes
for the C family of string functions?
- string.h
- io.h
- stdio.h
- mytype.h
- With the string compare function, what
value is returned if the two strings are the same?
- -1
- 0
- 1
- EOF
- The sprintf() function is useful for executing
which one of the following?
- Comparing two strings
- Determining print speed
- Executing system commands
- Concatenating two strings
- All of the following are character-testing
functions, except which one?
- isprint()
- isword()
- islower()
- isspace()
- A ___ line is the line you type to run your a program.
- argument
- system
- command
- comment
- What does argc stand for in the heading
int main(int argc, char * argv[])
- any character
- argument character
- a range count
- argument count
- Which one of the following means the same as
int main(int argc, char *argv[])
- int main(int *argc, char *argv[])
- int *main(int argc, char argv[])
- int main(int argc, char ** argv)
- int main(int argc, *(char *argv))
- Command-line arguments are read as ____.
- character constants
- strings
- numeric variables
- Both as strings and as numbers
- All of the following are string to
number conversion functions, except which one?
- atof()
- atoi()
- atol()
- atop()
- A ___ is a named section of storage, usually on a disk.
- pointer
- file
- array
- string
- The two ANSI-mandated views of a file are ___ and ___.
- text, inline
- binary, random
- random, inline
- binary, text
- Which three files does C open automatically?
- sdin, sdout, sderr
- sdi, sdo, sde
- stdin, stdout, stderr
- stin, stout, sterr
- Which function causes a program to terminate,
closing any open files?
- stop()
- exit()
- quit()
- end()
- All of the following are file mode strings for
fopen(), except which one?
- "u"
- "r"
- "w"
- "a"
- Which of the following mode strings opens a file
for update (for reading and writing)?
- "r+"
- "u+"
- "a"
- "w"
- What type of statement is the following?
FILE *fp;
- declares a pointer to an int
- declares a pointer to a character array
- declares a pointer to FILE
- declares a pointer to NULL
- When fp is a pointer to FILE, which one
of the following means the same as
ch = getchar();
- ch = gets(fp);
- ch = gets;
- ch = getc;
- ch = getc(fp);
- Which one of the following means the same as
putc(ch, stdout);
- puts(ch);
- putc(ch);
- putchar(stdout);
- putchar(ch);
- If fp is a pointer of type FILE,
which one of the following functions is
used to close a file?
- fclose();
- fclose(fp);
- close(FILE *fp);
- close(fp);
- Which one of the following is the
general format of the fgets() function?
- fgets(buf, MAX, fp);
- fgets(fp, MAX, buf);
- fgets(fp, buf, MAX);
- fgets(buf, fp, MAX);
- Which one of the following is the general form of
the fputs() function?
- fputs(buf, MAX, fp);
- fputs(fp, MAX, buf);
- fputs(buf, fp);
- fputs(fp, buf);
- The ___ function enables you to treat
a file like an array and move directly to
any particular byte in a file opened by fopen().
- flook()
- fget()
- fseek()
- fpick()
- Under ANSI, all of the following modes
can be used with fseek(), except which one?
- SEEK_BEG
- SEEK_CUR
- SEEK_END
- SEEK_SET
- In random access processing, which of the following
functions returns the current file location?
- fcur()
- fend()
- fseek()
- ftell()
- Calling the following function begins a
process called ____?
int fflush(FILE *fp)
/* this is the function header, not a call */
- filling a buffer
- floating a buffer
- fast-forwarding a buffer
- flushing a buffer
- Which one of the following functions
returns a nonzero error if a read or write
error has occurred during file processing?
- feof()
- ferror()
- ferr()
- feoff()
- A pointer-to-void type is written as _______.
- void ptr
- (void *) ptr
- (*void) ptr
- void * ptr
- Random access file processing works
better in ___ than in ___ mode.
- fscanf(), fprintf()
- binary, text
- text, binary
- text, character
|