Page 1 of 1

10. Assume that your buffer contains the C code shown here, with the Major mode set for C and the cursor positioned at t

Posted: Tue Jul 12, 2022 8:21 am
by answerhappygod
10. Assume that your buffer contains the C code shownhere, with the Major mode set for C
and the cursor positioned at the end of the while lineas shown by the black square:
/*
* Copy string s2 to s1. s1 must be largeenough
* 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. Thenour
caller
* can catenate to the dest * string without anotherstrlen
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 braceof strcpy? Which command
moves the cursor past the closing brace? Can you usethese commands to skip
through the buffer in one-procedure steps?
b) Assume the cursor is just past the closingparenthesis of the while condition. How do
you move to the matching opening parenthesis? How do youmove back to the
matching close parenthesis again? Does the same commandset work for
matched [] (square brackets) and {} (braces)? How doesthis differ from
the vim % command