The example program of C on Point

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.