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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply