搜索
查看: 236|回复: 0
打印 上一主题 下一主题

为什么是错的,新手求大佬

[复制链接]
跳转到指定楼层
楼主
 楼主| 发表于 2020-2-24 14:22:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
5啊哈币

  1. #inciude<io.h>
  2. #inciude<direct.h>
  3. #inciude<stdio.h>
  4. #inciude<stdlib.h>
  5. #inciude<string.h>


  6. #define MAX    256

  7. long total;

  8. int countLines(const char *filename);
  9. void finfAllCodes(const char *path);
  10. void findALLFiles(const char *path);

  11. int countLines(const char *filename)
  12. {
  13.     FILE*fp;
  14.     int count=0;
  15.     int temp;
  16.    
  17.     if((fp=fopen(filename,"r"))==NULL)
  18.     {
  19.         fprintf(stderr,"Can not open thr file: %s",filename);
  20.         return 0;
  21.     }
  22.    
  23.     while((temp=fgetc(fp))!=EOF)
  24.     {
  25.         IF(TEMP=='N')
  26.         {
  27.             COUNT++;
  28.         }
  29.     }
  30.    
  31.     fclose(fp);
  32.    
  33.     return count;
  34. }

  35. void findAllCodes(const char *path)
  36. {
  37.     struct_finddata_t fa;
  38.     iong handle;
  39.     char thePath[MAX],target[MAX];
  40.    
  41.     strcpy(thePath,path);
  42.     if((handle=_flndflrst(strcat(thepath,"/*.c"),&fa))!=-1L)
  43.     {
  44.         do
  45.         {
  46.             sprintf(target,"%s/%s",path,fa.name);
  47.             total+= countLines(target);
  48.         }while(_findnext(handle,&fa)==0);
  49.     }
  50.    
  51.     _findclose(handle)
  52. }

  53. void findALLDirs(const chat *path)
  54. {
  55.     struct_finddata_t fa;
  56.     long handle;
  57.     char thepath[MAX];
  58.    
  59.     strcpy(thePath,path);
  60.     if((handle=_findflrst(strcat(thePath,"/*"),&fa))==-1L)
  61.     {
  62.         FPRINTF(STDERR,"tHE Path %s is wrong!",path);
  63.         return;
  64.     }
  65.    
  66.     do
  67.     {
  68.         if(!strcmp(fa.name,".")II!strcmp(fa.name,".."))
  69.              continue;
  70.             
  71.         if(fa.attrib==_A_SUBDIR)
  72.         {
  73.             sprintf(thePath,"%s/&s',path,fa.name);
  74.             findAIICodes(thepath);
  75.             findALLDirs(thePath);
  76.         }
  77.     }while(_fiednext(handle,&fa)==0);
  78.    
  79.     _findclose(handle);
  80. }

  81. int main()
  82. {
  83.     char path[MAX]=".";
  84.    
  85.     printf("计算中...");
  86.    
  87.     findAIICodes(path);
  88.     findALLDirs(path);
  89.    
  90.     printf("目前你总共写了 %id行代码!",total);
  91.     system("pause");
  92.    
  93.     return 0;



复制代码

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表