哈哈楼,三克油
代码抄错了,不知道错在什么地方
哇 来看看
123
亲们
||=== 构建文件: "无目标" 在 "无项目" 中 (编译器: 未知的) ===|
E:\C学习\入门1\main.c||In function 'countLines':|
E:\C学习\入门1\main.c|24|warning: implicit declaration of function 'fpintf' [-Wimplicit-function-declaration]|
E:\C学习\入门1\main.o:main.c|| undefined reference to `fpintf'|
||error: ld returned 1 exit status|
||=== 构建 失败: 2个错误, 1个警告 (0 分, 1 秒) ===|
0
本帖最后由 飞行叶子 于 2018-11-10 11:51 编辑
计算中...
Can not open the file: .main.c
The path .bin is wrong!
The path .obj is wrong!
目前你总共写了 0 行代码!
请按任意键继续. . .
打印后是这个结果,对了好几遍,没找出问题,麻烦老师指点下!感谢
#include<io.h>
#include<direct.h>
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#define MAX256
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 thePth,target;
strcpy(thePth, path);
if((handle =_findfirst(strcat(thePth,"/*.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;
}
看看
答案是啥丫
学习学习学习好
厉害
看看我的答案对不对
这个会按时间记录所有的?如果是在这个程序之前写的他就不记录了?
答案
0
nice
谢谢
查看答案
答案