编写程序时的输入输出参数的编写常规

在编写程序时,一般有以下一些习惯;

1.对于函数的输入形参数,即:只传递变量的内容而不需要修改时,

 一般采用:1)传值方式:void  func( int   a );

      2)使用const:void func(const  int  a);

             void func(const  int*  a);

2.对于函数的输出形参数:对于一个函数返回多个参数时,一般采用函数形参返回;

 一般采用:1)传地址方式:void func(int  a,int  *p); 

举例:

  char *strcpy(char *dest, const char *src);//一眼望去,dest传地址方式,所以为输出参数;

                    //src为const方式,因此为输入形参数;

int func(int a,const int *b)
{
  *b=a+10;
  return 0;
}
原文地址:https://www.cnblogs.com/weiyouqing/p/7845112.html