C and pointer learning notes-3. array and pointer

Source: Internet
Author: User

Data name indicates the first address

Pointer to array

#include 
  
   extern void iterate(int *p);void main(){int a[]={1,2,3,4,5};iterate(a);}void iterate(int *p){int i;for(i=0;i<5;i++){printf("%d",*p++);}}
  


Pointer to a one-dimensional array

Int (* p) [3]

#include 
  
   void iterate(int (*p)[3]);void main(){int a[3][3]={{11,12,13},{14,15,16},{17,18,19}};iterate(a);}void iterate(int (*p)[3]){int i;int j;for(i=0;i<3;i++){for(j=0;j<3;j++){printf("%d\t",*(*(p+i)+j));}printf("\n");}}
  


Pointer Array


Char * p [3]

#include 
  
   void main(){char *strs[3] ;strs[0]="zhanhua";strs[1]="linin";strs[2]="wanwu";int i ;for(i=0;i<3;i++){printf("%s\t",*(strs+i));}}
  


Pointer

Char ** str

#include 
  
   void main(){char *strs[3] ;strs[0]="zhanhua";strs[1]="linin";strs[2]="wanwu";char **ps;ps=strs;int i ;for(i=0;i<3;i++){printf("%s\t",*(ps+i));}}
  







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.