Author: Stan Eisenstat
Subject: SECOND POSTING: Remark on Homework #3 strwrs
Date: Monday, 24 Feb 2020, 07:53:20
In case you missed it:
Date: 17 Feb 2020 08:32:42 -0500 (Mon)
Subject: Remark on Homework #3 strwrs
Hwk3/strwrs does not use
* strstr() or strcmp() (except for recognizing the -v
flag), since they do not work with fences and escapes
or with substrings.
* strdup() or stndup(), since there is little reason
to duplicate strings.
* strcat(), since it knows the length of the string to
which it is appending and uses strcpy() or strncpy()
instead (it could have used asprintf(), thereby saving
a few lines).
* realloc(), since it always creates the new string by
copying and only then frees the old one.
You cannot overemphasize the importance of adding null
terminators to strings and allocating space for them.
Best,
--Stan-
PREV
INDEX
NEXT