支持小甲鱼
来学习了{:10_266:}
感谢鱼C
为什么dp = opendir(path)) == NULL 这是True 打不开当前目录
#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;
}
此评论仅作者可见
#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#define MAX 256
;
int countlines ( const char * filename ) ;
void ficdAllCodes ( const char * path );
viod findALLFiles ( const char * path );
int countLines ( const char*filename )
{
FILE * fp;
int count = 0;
int temp;
if ( ( fp = fopen ( filename, "r")) == NULL)
{
fprintf ( stderr, "无法打开文件: %s\n",filename);
return 0;
}
while (( temp = fgetc ( fp ) ) ! = EOF )
{
if ( temp == '\n')
{
计数++;
}
}
FCLOSE ( FP );
返回计数;
}
void findALLCodes ( const char * path )
{
strnct finddata t fa;
长柄;
char thePath , 目标;
strcpy ( thePath, path);
if ((handle = _findfirst (strcat (thePath,"/ *。c"), &fa)) ! = -1L)
{
做
{
sprintf (target, "%s/%s",path, fa.name);
总计+ = countLines ( 目标 );
} while (_findnext (handle, &fa ) == 0);
}
_findclose (手柄);
}
void findALLDirs ( const char * path )
{
struct _finddata_t fa;
长柄;
char thePath ;
strcpy ( thePath, path );
if (( handle = _findfirst (strcat ( thePath,"/ *" ) ,&fa ) ) == -1L)
{
fprintf( stderr,"路径%s错了!\n",路径);
return;
}
做
{
if(!strcmp(fa.name,"。")||!strcmp ( fa.name,".." ) )
继续;
if( fa.attirb == _A_SUBDIR )
{
sprintf ( thePath,"%s/%s",path,fa.name);
findALLCodes ( thePath );
findALLDirs ( thePath );
}
} while (_findnext ( handle, &fa ) == 0 );
_findclose ( 手柄 );
}
int main()
{
char path = "。";
的printf( "计算中…\n");
findALLCodes (路径);
findALLDirs(路径);
printf("目前你总共写了%ld行代码!\n\n",总计);
系统("暂停");
return 0;
}
哈啊哈
1
为什么我做出来的结果是116行呢
努力,努力,再努力
第一天学习
为什么我的是你已经写了0行代码,不是复制了那么多吗
感谢分享
666
为什么我抄都抄错了
{:5_102:}
{:5_105:}
111
55555555