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

  

  

 

posted @ 2014-01-12 21:52  bradleydan  阅读(142)  评论(0)    收藏  举报