Advanced Exercises
10. | 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(s1, s2) register char *s1, *s2; { register 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 concatenate to the dest string without another strlen call. */ char * stpcpy (dest, source) char *dest; char *source; { while ((*dest++ = *source++) != '\0') ▀ ; /* void loop body */ return (dest - 1); }
|
Get A Practical Guide to Red Hat® Linux® 8 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.