想问下这是什么问题啊?
请教问下各位大佬 两个找不到定义没有退出 return 0; ?
附代码吧~~ 链接器不正常退出,可能因为没有找到函数体(只有函数声明没有函数体的空函数)。
#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX
long total;
int countLines(const char *filename);
void findAllCodes(const char *path);
void findALLFILES(const char *path);
int countLines(const char *filename)
{
FILE *fp;
int count = 0;
int temp;
if ((fp = fopen(filename, "r")) == NULL)
{
fprintf(stderr, "Can not open the file:%s\n, filename");
return 0;
}
while ((temp = fgetc(fp)) != EOF)
{
if (temp =='\n')
{
count++;
}
}
fclose(fp);
return count;
}
void findALLCodes(const char *path)
{
struct _finddata_t fa;
long handle;
char thePath, target;
strcpy(thePath, path);
if((handle = _findfirst(strcat(thePath, "/*.c"),&fa))!=-1L)
{
do
{
sprintf(target, "%s/%s", path, fa.name);
total +=countlines(target);
}while (_findnext(handle, &fa) == 0);
}
_findclose(handle);
}
void findALLDirs(const char *path)
{
struct _finddata_t fa;
long handle;
char thePath;
strcpy(thePath, path);
if((handle = _findfirst(strcat(thePath,"/*"),&fa)) == -1L)
{
fprintf(stderr, "The path %s is wrong!\n",path);
return;
}
do
{
if (!strcmp(fa.name,".") || !strcmp(fa.name,".."))
continue;
if( fa.attrib == _A_SUBDIR)
{
sprintf(thePath, "%s/%s", path, fa.name);
findALLCodes(thePath);
findALLDirs(thePath);
}
}while (_findnext(handle, &fa) == 0);
_findclose(handle);
}
int main()
{
char path = ".";
printf("计算中...\n");
findALLCodes(path);
findAllDirs(path);
printf("目前你总共写了 %ld 行代码!\n\n", total);
system("pause");
return 0;
} 就那个小甲鱼那个练习的代码 53行和96行,函数名字写错,因为c语言支持默认int返回值,所以语法检测过了,但是由于链接器无法找到函数本体出错。
谢了谢了,我是初学者
页:
[1]