Assume that your buffer contains the C code shown here, with the Major mode set for C and the cursor positioned at the end of the while line as shown by the black square:

/*
* Copy string s2 to s1. s1 must be large enough
* return s1
*/
char *strcpy(char *s1, char *s2)
{
char *os1;
os1 = s1;
while (*s1++ = *s2++)
;
return os1;
}
/*
* Copy source into dest, stopping after '\0' is copied, and
* return a pointer to the '\0' at the end of dest. Then our
caller
* can catenate to the dest * string without another strlen call.
*/
char *stpcpy (char *dest, char *source)
{
while ((*dest++ = *source++) != '\0') ?
; /* void loop body */
return (dest - 1);
}

a. Which command moves the cursor to the opening brace of strcpy? Which
command moves the cursor past the closing brace? Can you use these
commands to skip through the buffer in one-procedure steps?
b. Assume the cursor is just past the closing parenthesis of the while condi-
tion. How do you move to the matching opening parenthesis? How do
you move back to the matching close parenthesis again? Does the same
command set work for matched [] (square brackets)
c. One procedure is indented in the Berkeley indention style; the other is
indented in the GNU style. Which command reindents a line in accor-
dance with the current indention style you have set up? How would you
reindent an entire procedure?
d. Suppose that you want to write five string procedures and intend to use
strcpy as a starting point for further editing. How would you make five
copies of the strcpy procedure?
e. How would you compile the code without leaving emacs?


a. With the cursor at the start of the file, give the command CONTROL-META-e to
move the cursor past the closing brace of strcpy; CONTROL-META-a moves it back
to the opening brace. You can use these commands to skip from procedure
to procedure.
b. CONTROL-META-b moves backward over an expression and CONTROL-META-f moves
forward over an expression. The expression can be delimited by (), [], or {}.
The vim % command requires that you position the cursor on the same line
as, and on or to the left of, the closing element of the expression. Then %
jumps between the opening and closing elements.
c. Press TAB while the cursor is positioned anywhere on a line to reindent the
line to the current indention style. Position the cursor before a pair of
matched braces and press CONTROL-META-q to reindent the lines within the
braces to the current style.
d. Move the cursor to the beginning of the word strcpy and press CONTROL-SPACE to
set Mark. Move the cursor to the line past the closing brace and press META-w
to copy Region nondestructively to the Kill Ring. Finally, press CONTROL-Y five
times to yank five copies of the killed Region into the Work buffer.
e. After saving the buffer, give the command META-x compile. You will be
prompted for a command; respond with the command to compile the file
you are working on. The output of the compilation appears in a buffer
named *compilation*.

Computer Science & Information Technology

You might also like to view...

Two tools used by programmers to design programs before writing actual code are __________ and __________

Fill in the blank(s) with correct word

Computer Science & Information Technology

Illegal copies of software are referred to as _______ software.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Before you can close a database, you must save each object in the database.

a. true b. false

Computer Science & Information Technology

A(n) display screen is a programmable, electronic device that accepts data, performs operations on that data, presents the results, and stores the data or results as needed. _________________________

Answer the following statement true (T) or false (F)

Computer Science & Information Technology