|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<io.h>
#include<direct.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 256
long total;
int countlines(const char *fliename);
void findallcodes(const char *path);
void findallfiles(const char *parth);
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[MAX],target[MAX];
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(cont char *path)
{
struct_finddata_t fa;
long handle;
char thepath[MAX];
strcpy(thepath,path);
if((handle=_findfirst(strcat(thepath,"/*"),&fa))=-1L)
{
fprintf
}
do
{
if(!strcmp(fa.name,".")||!strcmp(fa.name,".."))
continue;
if(fs.attri==_A_SUBDIR)
{
sprintf(thepath,"%s/%s",path,fa.name);
findallcodes(thepath);
findalldirs(thepath);
}
}whule(_findclose(handle,&fa)==0);
_findclose(handle);
}
int main9
{
char path[MAX]=".";
printf("计算中...\n");
findallcodes(path);
findalldirs(path);
printf("目前你总共写了%ld行代码!\n\n",total) ;
system("pasue");
return 0;
}
你这代码BUG有点多啊。。
1,89行,int main9是啥?
2,你说报错的那个地方,是const不是cont
3,68行末尾,那里是==还是!=?
4,70行那个单独的fprintf是?
|
|