区别"的char []名"和"焦炭名[]"在C函数的参数 [英] Difference between "char[] name" and "char name[]" as a function's argument in c

查看:187
本文介绍了区别"的char []名"和"焦炭名[]"在C函数的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在定义这样的功能:

void  myFunction(arguments){
   // some instructions
}

什么是使用之间的差额的char []的名字字符名称[] 作为函数的参数。为什么不使用指针,而不是为char。

what is the deference between using char[] name and char name[] as the function's argument. And why not use a pointer to char instead.

推荐答案

1. ST 一(的char []的名字)不会编译,因为它是错误的语法。

The 1st one (char[] name) won't compile as it's the wrong syntax.

在一个函数的执行参数的定义阵列subcripts去(强制)参数的名称。

Array subcripts in definitions for the parameters of a function's implementation go to the name of (mandatory) parameter.

正确的语法是2 第二

char name[]

例如:

void p(char[]); /* prototype */

void p(char name[]) /* implementation */
{
}

的char []的名字将被视为无效的语法。

这篇关于区别"的char []名"和"焦炭名[]"在C函数的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆