鱼C论坛

 找回密码
 立即注册
查看: 2101|回复: 3

[已解决]新手 出现这个错误该怎么办

[复制链接]
发表于 2018-11-2 20:53:03 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
用linux  照抄的
https://fishc.com.cn/forum.php?m ... peid%26typeid%3D570
这个的动动手
  1. /tmp/ccuXUXk8.o:在函数‘findAllDirs’中:
  2. kehou.c:(.text+0x168):对‘isCode’未定义的引用
  3. kehou.c:(.text+0x17c):对‘countLines’未定义的引用
  4. collect2: 错误:ld 返回 1
复制代码
最佳答案
2018-11-2 21:55:06
老板哪个动动手?

照抄 也要把你的代码传上来,别人才知道哪里的问题吧!

很多照抄都抄错的。不止你一个。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-11-2 21:55:06 | 显示全部楼层    本楼为最佳答案   
老板哪个动动手?

照抄 也要把你的代码传上来,别人才知道哪里的问题吧!

很多照抄都抄错的。不止你一个。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-11-2 22:01:09 | 显示全部楼层
本帖最后由 h1322443670 于 2018-11-2 22:20 编辑

的确是漏了一段
写全后 又出现新的错误

ehou.c: 在函数‘isCode’中:
kehou.c:50:3: 错误:‘returm’未声明(在此函数内第一次使用)
   returm 1;
   ^
kehou.c:50:3: 附注:每个未声明的标识符在其出现的函数内只报告一次
kehou.c:50:10: 错误:expected ‘;’ before numeric constant
   returm 1;
          ^


  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <dirent.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #include <sys/stat.h>

  7. #define MAX 256

  8. long total;

  9. int countLines(const char *filename);
  10. int isCode(const char *filename);
  11. void findAllDirs(const char *path);

  12. int countLinrs(const char *filename)
  13. {
  14.        
  15.         FILE *fp;
  16.         int count = 0;
  17.         int temp;

  18.         if((fp = fopen(filename,"r")) == NULL)
  19.         {
  20.                 fprintf(stderr,"Can not open the file: %s\n", filename);
  21.                 return 0;
  22.         }
  23.        
  24.         while ((temp = fgetc(fp)) !=EOF)
  25.         {
  26.                 if (temp == '\n')
  27.                 {
  28.                         count++;
  29.                 }
  30.         }

  31.         fclose(fp);

  32.         return count;
  33. }

  34. int isCode(const char *filename)
  35. {
  36.         int length;

  37.         length = strlen(filename);

  38.         if (!strcmp(filename + (length -2),".c"))
  39.         {
  40.                 returm 1;
  41.         }
  42.         else
  43.         {
  44.                 return 0;
  45.         }
  46. }

  47. void findAllDirs(const char *path)
  48. {
  49.         DIR *dp;
  50.         struct dirent *entry;
  51.         struct stat statbuf;

  52.         if ((dp = opendir(path)) == NULL)
  53.         {
  54.                 fprintf(stderr, "The path %s is wrong!\n",path);
  55.                 return;
  56.         }

  57.         chdir(path);
  58.         while ((entry = readdir(dp)) != NULL)
  59.         {
  60.                 lstat(entry->d_name,&statbuf);

  61.                 if (!strcmp(".",entry->d_name) || !strcmp("..",entry->d_name))
  62.                         continue;

  63.                 if(S_ISDIR(statbuf.st_mode))
  64.                 {

  65.                         findAllDirs(entry->d_name);

  66.                 }
  67.                 else
  68.                 {
  69.                         if (isCode(entry->d_name))
  70.                         {
  71.                                 total += countLines(entry->d_name);

  72.                         }
  73.                 }
  74.         }

  75.         chdir("..");
  76.         closedir(dp);
  77. }

  78. int main()
  79. {
  80.         char path[MAX]= ".";
  81.         printf("计算中。。。\n");

  82.         findAllDirs(path);

  83.         printf("目前你共写了%ld行代码\n\n",total);

  84.         return 0;
  85. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-11-2 22:21:21 | 显示全部楼层
ba21 发表于 2018-11-2 21:55
老板哪个动动手?

照抄 也要把你的代码传上来,别人才知道哪里的问题吧!

好吧 的确是抄错了  经过逐字逐句的检查 全部解决
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-11 10:34

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表