GCC编辑器基本知识
多文件编译
string.c文件
#define ENDSTRING '\0'
int StrLen(char *string)
{
int len=0;
while(*string++!=ENDSTRING)
len++;
return len;
}
main.c 文件
#include<stdio.h>
extern int StrLen(char *str);
int main(void)
{
char src[]="Hello Dynamic";
printf("%d",StrLen(src));
return 0;
}
多文件编译和运行结果
[dong@localhost test]# gcc -o test main.c string.c [dong@localhost test]# ./test 13

浙公网安备 33010602011771号