查看参考答案
看看答案
11111111
无法打开源文件:字符串
{:10_277:}
666
太难了,我直接复制粘贴
.
吼吼吼
$ gcc count_lines.c -o count_lines
$ ./count_lines
计算中...
目前你总共写了 105 行代码!
$
照抄谁不会!
1
1
#include <window.h>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define max 256
;
int countLines(const char *filename);
void findAllCodes(const char *path);
void findALLFiles(const char *path);
int countLines(const char *filename)
{
File *fp;
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;
长手柄;
char thePath, target;
strcpy(thePath, path);
if((handle = _findfirst(strcat(thePath, "/*.c"), &fa)) != -1L)
{
做
{
sprintf(target, “%s/%s”, path, fa.name);
sum += count线(目标);
}while (_findnext(handle, &fa) == 0);
}
_findclose(手柄);
}
void findALLDirs(const char *path)
{
结构_finddata_t法;
长手柄;
char thePath;
strcpy(thePath, path);
if((handle = _findfirst(strcat(thePath, “/*”), &fa)) == -1L)
{
fprintf(stderr, “path %s is error!\n”,path);
return;
}
做
{
if (!strcmp(fa.name, “.”) || !strcmp(fa.name, “..”))
继续;
if( fa.attrib == _A_SUBDIR)
{
sprintf(thePath, “%s/%s”, path, fa.name);
findAllCodes(thePath);
findALLDirs(thePath);
}
}while (_findnext(handle, &fa) == 0);
_findclose(手柄);
}
int main()
{
字符路径 = “.”;
printf(“计算中...\n”);
findAllCodes(path);
findALLDirs(path);
printf(“目前你总共写了 %ld 行代码!\n\n”, total);
stream(“暂停”);
return 0;
}
太厉害啦
1
333
看看答案
来对答案了
报错