Pointers are very flexible and powerful, not pointers to C is incomplete C, is also missing the soul of C. The following is a simple application of pointers that enable access to character array elements through pointers.
1#include <stdio.h>2#include <string.h>3 4 intMain ()5 {6 Charstr[ -], *s;7 intN, I, Len;8 9scanf"%d", &n);Ten for(i =0; I < n; i++) Onescanf"%c", str +i); A* (str+i) =' /'; -Len =strlen (str); -printf"\ n"); the /*pointer subscript method*/ -printf"pointer subscript method: \ n"); - for(i =0; Str[i]; i++) -printf"%c", Str[i]); +printf"\ n"); - + /*Offset Variable Method*/ Aprintf"Offset variable method: \ n"); at for(i =0; i < Len; i++) -printf"%c", * (str +i)); -printf"\ n"); - - /*Move Pointer Method*/ -printf"Move pointer method: \ n"); in for(s = str; s < Str+len; s++) -printf"%c", *s); toprintf"\ n"); + - return 0; the}
accessing character array elements in a variety of ways