#include<io.h>
#include<direct.h>
#include<stdio.h>
#include<stdio.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)) != EOP)
{
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(stract(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(stract(thePath, "/*"), &fa)) == -1L)
{
fprintf(stderr, "The Path %s is wrong!\n",path);
return;
}
do
{
if(!strcpm(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, 7fa) == 0);
_findclose(handle);
}
int main()
{
char path = ".";
printf("计算中...\n");
findALLCodes(path);
findALLDirs(path);
printf("目前你总共写了 %1d 行代码! \n\n", total);
system("pause");
return 0;
}
答案
1
看看答案,说要回复
宝宝
刚开始打字母是有点烦人{:5_104:}
查看参考答案
66
初学者没有找明白
1
呜呜抄都能抄歪来
CCC
看看答案
llll
0、计算机只会二进制,不会二以上的数
1、机械语言
2、忘记了...
3、是否需要翻译
4、可以
5、不同的翻译器
6、不同的符号排列代表不同的含义
动动手
666
b
findALLDirs(path);这个我们定义过吗
谢谢分享
.