厉害了
1
给我答案
11111
嗯嗯
查看参考答案
。
对答案{:5_109:}
感谢分享
!!
感谢帮助!
102行。。。图片不会贴
答案
..
D:FishC
# vim daimaliang.c
# gcc daimaliang.c
# ll
total 20
-rwxr-xr-x 1 root root 13520 Mar 17 17:22 a.out
-rw-r--r-- 1 root root2127 Mar 17 17:22 daimaliang.c
# ./a.out
计算中...
目前你总共写了 105 行代码!
#
np
本帖最后由 单一色 于 2020-3-17 18:50 编辑
{:10_285:}输完了,显示错误,第二行的#include <unistd.h>,好像复制老师的代码,也是这行报错
#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 _finddate_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 _finddate_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(!strcap(fa.name,".") || !strcap(fa.name,".."))
continue;
if ( fa.attrib == _A_SUBDIR)
{
spintf(thePath,"%s/%s", path, fa.name);
findAllCodes(thePath);
findALLDirs(thePath);
}
}while (_findnext(handle, &fa) == 0);
_findclse(handle);
}
int main()
{
char path = ".";
printf("计算中...\n");
findAllCodes(path);
findALLDirs(path);
printf("目前你总共写了 %ld 行代码!\n\n", total);
system("pause");
return 0;
}
45 21 C:\Users\Administrator\Documents\code\kh1.c storage size of 'fa' isn't known
64 21 C:\Users\Administrator\Documents\code\kh1.c storage size of 'fa' isn't known
大佬owo