Linux C \ C ++ base - array parameter is used

1. The array parameter

void fun(int a[100])
void fun(int a[])
void fun(int *a)
void fun(char*p[100],int n)
void fun(char*p[],int n)
void fun(char**p,int n)

If the array as a function parameter, the array pointer is shaped participants degradation, the above code compiler appears to be equivalent to

2. Description of the parameter used in the main function

Both versions of the main function parameter

int main(int argc,char**argv)
int  main(int argc,char *argv[])
  • argv []: It is an array, each element is an array of type char *, each element address string
  • The number of the argv [] element: argc
  • main () function parameter, the user needs to pass
  1 #include<stdio.h>                                                                                          
  2 
  3 int main(int argc,char *argv[])
  4 {
  5     for(int i=0;i<argc;i++)
  6     {
  7        printf("test=%s\n",argv[i]);
  8     }
  9 
 10     return 0;
 11 }

 

 

 

 

Guess you like

Origin www.cnblogs.com/xiangdongBig1/p/11899824.html