C如何处理函数调用

问题描述 投票:0回答:1
#include <stdio.h>
#include <string.h>

char ahv_number[20] = "XXXXXXX";
char birthday[15] = "XXXXX";
char name_first[100] = "XX";
char name_last[100] = "NN";
char name_full[100];
char name_abbreviation[5];


int main() {
  printf("My name is %s %s, I'm born %s and my AHV number is %s\n", name_first, name_last, birthday, ahv_number);
  FullName();
  return(0);
}

int FullName() {
  strcpy(name_full, name_first);
  strcat(name_full, " ");
  strcat(name_full, name_last);
  printf("%s", name_full);
  return(0);
}

你好,我在运行这个小程序时遇到了麻烦。我是C语言的新手,很抱歉,如果它被问了数百遍,但是并没有真正得到C语言如何处理函数调用的有用解释。

对我来说,如果代码没有在主函数中显式调用FullName(),它应该可以工作。但是由于某些原因-我想知道

-它仅在代码包括main()中的FullName()函数调用时才起作用。

警告:函数'FullName'的隐式声明在C99中无效[-Wimplicit-function-declaration]

我仍然收到此警告消息,但是代码运行正常。

你们知道C编译器如何在现实中编译代码吗?

#include #include char ahv_number [20] =“ XXXXXXX”;字符生日[15] =“ XXXXX”; char name_first [100] =“ XX”; char name_last [100] =“ NN”; char name_full [100];字符...

c function-call
1个回答
0
投票

C编译器是单遍编译器,因此必须在使用符号之前对其进行定义。

© www.soinside.com 2019 - 2024. All rights reserved.