Procedure 1:
# Include <stdio. h> # define n_values 5int main (void) {float values [n_values]; float * VP; For (Vp = & values [0]; VP <& values [n_values];) * VP ++ = 0; For (Vp = & values [n_values]; VP> & values [0];) * -- Vp = 0; for (Vp = & values [n_values]; VP >=& values [0]; VP --) * Vp = 0; // The array subscript is not recommended to cross-border // The standard allows the pointer pointing to the array element to compare with the pointer at the memory position of the last element // the pointer at the first element and the previous memory position is not allowed compare return 0 ;}Procedure 2:
/*** Programe6.1 ** function for calculating a string */# include <stdio. h> int strlen (char * string) {int lenth = 0; while (* string ++! = '\ 0') lenth ++; return lenth;} int main (void) {char * string = NULL; string = "zxczxc"; printf ("% d ", strlen (string); Return 0 ;}
It's fun to write a library function by yourself ~
Procedure 3:
/*** Programe6.2 search for Version 1 in a set of strings **. Given a pointer to the pointer list ending with null, search for a specific character in the list string. */# Include <stdio. h> # define true 1 # define false 0int find_char (char ** strings, char value) {char * string; // our current source string/*** processes each string in the list */while (string = * strings ++ )! = NULL) {/*** traverse whether each string is the target string */while (* string! = '\ 0') {If (* string ++ = value) return true ;}} return false;} int main (void) {char * STR [3] [10] = {"SDF", "sdfdhf", "fdghdf"}; int result = find_char (STR [0], 'x '); printf ("% d", result); Return 0 ;}The pointer pointing to the array is not actually tested by blind means ~
The example program of C on Point