永发信息网

定义函数的时候(int,int,int)和(int x,int y,int z)有什么区别? 什么时

答案:1  悬赏:70  手机版
解决时间 2021-02-01 09:51
  • 提问者网友:最美的风景
  • 2021-01-31 21:31
定义函数的时候(int,int,int)和(int x,int y,int z)有什么区别? 什么时候可以省略参数
最佳答案
  • 五星知识达人网友:不想翻身的咸鱼
  • 2021-01-31 22:26
函数的声明,要在 主函数之前。 比如: 写求字符串函数 (1) 你可以在 主函数前写,会正确。比如: int stringLength(char *p) { int count = 0; while ( *p != 0) count++; return count; } int main() { printf("%d",stringLength("Hello World !")); } (2) 你可以在 主函数 之后 写,会报错确。(也 编译器不报错,但是原则上是错误的)比如: int main() { printf("%d",stringLength("Hello World !")); } int stringLength(char *p) { int count = 0; while ( *p != 0) count++; return count; } (3) 这个时候, 1.你就 必须在 主函数之前写。 2.在主函数前,申明这个函数 int strLength(char *) ; 这个时候,就可以 不用 形参。 整个例子。 int strLength(char *) ; int main() { printf("%d",stringLength("Hello World !")); } int stringLength(char *p) { int count = 0; while ( *p != 0) count++; return count; }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯