An interesting code

Source: Internet
Author: User

An interesting code

0. Know how to output the AsCii code of a character. The ASCII code is in decimal format and cannot be '\ (ASCII)' directly. First, convert the ASCII code to octal format, and then use '\'

1. Review while (): When the value in the brackets is0 or '\ 0'The cycle ends. (The value '0' in the brackets is not terminated)

2. Review string pointer:

Char * s = "ABCDEF ";

Assign the address of A to the pointer s, so * s is A, and so on, * (s + 1) is B, * (s + 2) is C

3. Program

 

Code:

# Include <stdio. h>
Int main ()
{
Char * s = "ABCDEF ";
While (* s)
Printf ("% s \ n", s ++ );
}

 

From this we can see that the string defined by the pointer can control the position where the string starts printing from the address. This position is not necessarily from the front to the back, but also from the back to the front.

If you encounter a problem with the string pointer, you can use the pointer variable to find the characters in the string, but not the character address in the string to find the pointer/

Related Article

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.