首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

关于header, .c与main()文件之间的连接编译不通过有关问题

2012-02-29 
关于header, .c与main()文件之间的连接编译不通过问题,现在有三个文件:头文件DelZero.h:在main中所用到的

关于header, .c与main()文件之间的连接编译不通过问题,
现在有三个文件:
头文件   DelZero.h   :在main中所用到的函数声明;
源文件   DelZero.c   :定义DelZero.h中所有声明的函数;
主文件   DelZeroMain.c   :程序入口,调用以上的函数。
/*
****************************
DelZero.h:
****************************
*/
#ifndef   _DELZERO_h

#define   _DELZERO_h

extern   int   cchkdig(char   *r);
extern   void   cdel0(char   *r);
extern   int   scmp(char   *r,   char   *u);
       
#endif

/*
****************************
DelZero.c
****************************
*/
#include   <stdio.h>  
#include   <stdlib.h>  
#include   <string.h>  
#include   <ctype.h>  

/*
*************************************************************
        Check   all   charactor,   is   in   [0..9].  
*************************************************************
*/
int   cchkdig(char   *r)  
{  
    int   i=0;    
    while(r[i]!= '\0 ')  
    {  
        if(isdigit(r[i++])==0)  
            return   0;  
    }  
    return   1;    
}  

/*
*************************************************************
    Delete   all   front   zero   in   the   string   "r ".
*************************************************************
*/
void   cdel0(char   *r)  
{
    unsigned   int   lr=0;    
    unsigned   i=0,   j=0;  
    lr=strlen(r);    
    while(r[i]== '0 ')  
        ++i;
    if(i> 0)  
    {
        for(j=0;   j <lr-i;   ++j)
            r[j]=r[j+i];
        for(j=lr-i;   j <lr;   ++j)  
            r[j]= '\0 ';  
    }    
    if(r[0]== '\0 ')
        r[0]= '0 ';
}  

/*
*************************************************************
    compare   two   strings  
*************************************************************
*/
int   scmp(char   *r,   char   *u)  
{          
    unsigned   int   lr,   lu;  
    cdel0(r);
    cdel0(u);  
   
    lr=strlen(r);  
    lu=strlen(u);  
   
    if(lr> lu)  
    {
        return   1;
    }
    else   if   (lr <lu)  
    {
        return   -1;
    }
    return   (strcmp(r,   u));  
}


/*
****************************
DelZeroMain.c
****************************
*/
#include   <stdio.h>  


#include   <stdlib.h>  
#include   <string.h>
#include   "DelZero.h "   //此处调用函数。

int   main(int   argc,   char   *argv[])  
{  
    char   *p= "123 ",   *r= "87 ",*ret,*rout;  
    char   *h= "192 ";    
    int   n;    
    cdel0(p);  
    cdel0(r);  
    printf( "P   is:   %s\n ",   p);
    printf( "P   length   is:   %d\n ",strlen(p));  
    printf( "R   is:   %s\n ",   r);  
    printf( "R   length   is:   %d\n ",strlen(r));    
    n=scmp(p,h);      
    scanf( "%d\n ",&n);    
    return   0;
}

编译环境:Dev-C++   4.9.9.2
提示错误:
    command   not   found  
  C:\DelZero\Makefile.win   [Build   Error]     [DelZeromain.o]   Error   127  

Compile   Log:
Compiler:   Default   compiler
Building   Makefile:   "C:\DelZero\Makefile.win "
Executing     make...
make.exe   -f   "C:\DelZero\Makefile.win "   all
gcc.exe   -c   DelZeromain.c   -o   DelZeromain.o   -I "C:/Dev-Cpp/include "      

/usr/bin/sh:   gcc.exe:   command   not   found
make.exe:   ***   [DelZeromain.o]   Error   127

Execution   terminated

麻烦大家了,多谢!

[解决办法]
这个程序结构没有任何问题 ~
[解决办法]
不论学习的是什么语言,我都建议大家从基本的命令行工具开始掌握,不要只会用IDE。那样在不能使用IDE,或者需要进行自动化工作的时候就会束手无策了。

热点排行