From: Jeffrey Altman Date: Wed, 15 Jul 2009 06:41:03 +0000 (-0400) Subject: To reference one element of a C-string use [] X-Git-Tag: openafs-devel-1_5_61~108 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=0732d4505654fb51daf6302439b467dffcbe7d3d;p=packages%2Fo%2Fopenafs.git To reference one element of a C-string use [] Reported by Marcus Watts Pointer arithmetic is inappropriate when attempting to output one of the elements of an array or C-string. LICENSE IPL10 Reviewed-on: http://gerrit.openafs.org/90 Verified-by: Russ Allbery Reviewed-by: Russ Allbery --- diff --git a/src/gtx/textobject.c b/src/gtx/textobject.c index b589cba50..9604558b9 100644 --- a/src/gtx/textobject.c +++ b/src/gtx/textobject.c @@ -436,7 +436,7 @@ gator_text_Write(struct onode *onp, char *strToWrite, int numChars, "[%s:%s] Writing %d chars to text object at %p (highlight=%d, skip=%d: '", mn, rn, numChars, onp, highlight, skip); for (i = 0; i < numChars; i++) - fprintf(stderr, "%c", strToWrite + i); + fprintf(stderr, "%c", strToWrite[i]); fprintf(stderr, "\n"); }