Summary of C language pointers

Source: Internet
Author: User

Summary of C language pointers

# Include
 
  
Void main () {int a [3] = {1, 3, 5}; // One-dimensional array int * num [3] = {& a [0], & a [1], & a [2]}; // pointer array int ** p pointing to the pointer int I of a one-dimensional array with an array length of 3; p = num; // pass the first address of num to p. p stores the first address of num for (I = 0; I <3; I ++) {printf ("& p % d = % d \ t", I, & p ); // specifies the address of the pointer to the pointer printf ("p % d = % d \ t", I, p ); // printf ("* p % d = % d \ t", I, * p ); // printf ("& num [% d] = % d \ t", I, & num [I]); // num [I] address printf ("num [% d] = % d \ t", I, num [I]); // num [I] The address value printf ("& a [% d] = % d \ t", I, & a [I]); // The address printf ("% d \ n", ** p) of a [I ); // The value stored on the address pointed to by the pointer to p ++ ;}}
 

# Include
 
  
Void main (int argc, char * argv []) // Number of argc function parameters argv points to each parameter {printf ("argc = % d \ n", argc ); for (int I = 0; I
  

# Include
   
    
// Void main () {int a [5] = {1, 2, 3, 4, 5}; int * p1, * p2; p1 = & a [0]; p2 = & a [4]; printf ("% d \ n", P2-P1); // point to the same Array pointer minus if (p2> p1) // compare printf ("% d \ n", * p2) with the array pointer; elseprintf ("% d \ n", * p1 );}
   


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.