PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Remark on Homework #3 strwrs
Date: Monday, 17 Feb 2020, 08:32:43


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