/* * Requires: * "s" is a properly terminated string. * * Effects: * Reverses a string (from K&R). This function can be safely called by a * signal handler. */ static void sio_reverse(char s[]) { int c, i, j; for (i = 0, j = sio_strlen(s) - 1; i < j; i++, j--) { c = s[i]; s[i] = s[j]; s[j] = c; } }
ssize_t sio_puts(char s[]) /* Put string */ { return write(STDOUT_FILENO, s, sio_strlen(s)); //line:csapp:siostrlen }
/* * Requires: * "s" is a properly terminated string. * * Effects: * Prints the string "s" to stdout using only functions that can be safely * called by a signal handler, and returns either the number of characters * printed or -1 if the string could not be printed. */ static ssize_t sio_puts(char s[]) { return (write(STDOUT_FILENO, s, sio_strlen(s))); }