请教大佬们 ,运行出来是205行代码跟鱼c哥给出答案101行是不同的 是哪里出问题了。.
#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 256
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;
}
data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAg8AAAC0CAYAAAATt889AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABtYSURBVHhe7dzr7zVXVcDx/jn1f+AfaIwW8xCVNETFNGoxJiaEF0YxagyX2lZukULLpYCQSktaYriWPpT6QhBjkeKlQa0aTWyf3kBa5MV49sysmTVr1tq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PySKF+31zp1PQDgzOU2D/pvRGqsfWMiyinVStzmtfRn+8jlRFI8qi/VJlLv5Upb1E+utsap6nWdx6sBAJxAtHnQk3U0cecm9FJNrjbZ55xJ1H/u2ItJm/2bI3U2t3Ss2716rbav65G+f49XAwA4gdwvD6Vjb0KviUXHmu6nxNbYz55crhx77RGdo2ukrUTn6lotiuVqricyFhGvBgBwAt7mwfIm7txkbmO5yb+1vYWcN+LVnKPS9V5P95Ij9xnxagAAJ1CzeQAAAJiweQAAAE3YPAAAgCZsHgAAQBM2DwAAoAmbBwAA0ITNAwAAaMLmAQAANGHzAAAAmrB5AAAATdg8AACAJmweAABAEzYPAACgCZsHAADQhM0DAABowuYBAAA0YfMAAACasHkAAABN2DwAAIAmbB4AAEC9m7r/B7XIDreJhGnxAAAAAElFTkSuQmCC
完整的代码是
#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 256
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;
} 本帖最后由 baige 于 2020-9-19 22:01 编辑
统计当前目录及所有子目录下,C 语言源文件的代码总行数。
它不只统计这个程序,还统计当前目录及其子目录的C程序的代码行数 {:5_104:}
你的程序数的是你写的代码行数,小甲鱼的程序数的是他的代码行数。结果不一样难道不正常吗?
你把这个程序文件换一个文件夹,计算的结果又不一样了呢
重新新建个文件夹,然后将你这个代码文件拷贝到那个文件夹后运行代码
应该就是 101 行了,即 101 行是你这个代码文件的行数
而你超过 101 行就说明文件夹中有其他的 .c 代码文件咯,能正常运行即可,不必纠结行数问题
空行,花括号在下一行,都会使你的程序运行结果不一样的 Twilight6 发表于 2020-9-19 22:04
重新新建个文件夹,然后将你这个代码文件拷贝到那个文件夹后运行代码
应该就是 101 行了,即 101 行 ...
哈哈谢谢了 问题解决了 sunrise085 发表于 2020-9-19 22:03
你的程序数的是你写的代码行数,小甲鱼的程序数的是他的代码行数。结果不一样难道不正常吗?
...
恩恩刚才尝试了是这样的{:5_109:} zhijie 发表于 2020-9-19 23:00
恩恩刚才尝试了是这样的
呃,那你就选了别人为最佳答案。。。。 sunrise085 发表于 2020-9-19 23:02
呃,那你就选了别人为最佳答案。。。。
他回复快的呀{:5_104:} zhijie 发表于 2020-9-19 23:13
他回复快的呀
快吗?我的回答在四楼,他在六楼哎
再者,他所说的能解答你的问题?
乱选最佳答案,不合适吧 sunrise085 发表于 2020-9-19 23:16
快吗?我的回答在四楼,他在六楼哎
再者,他所说的能解答你的问题?
乱选最佳答案,不合适吧
好吧 我冲动{:5_111:}了 zhijie 发表于 2020-9-19 23:19
好吧 我冲动了
那位鱼油一直很不错,我也不再要这个最佳了,以后请注意。
乱选最佳影响回答者的积极性,
也会使后来人查找问题也会受到影响,不能快速找到想要的结果。 sunrise085 发表于 2020-9-19 23:27
那位鱼油一直很不错,我也不再要这个最佳了,以后请注意。
乱选最佳影响回答者的积极性,
也会使后来人 ...
好的 我会慎重考虑了 谢谢您的建议。
页:
[1]