iwannabest 发表于 2019-3-3 18:10:29

{:5_90:}

yyc435845207 发表于 2019-3-3 21:44:45

0只认识机器语言
1c语言
2编程
3代码

Mike666995 发表于 2019-3-3 21:46:04

1

jerrychou 发表于 2019-3-4 00:13:27

第一次回帖,支持小甲鱼

小寰宇 发表于 2019-3-4 00:34:21

0行代码。。。

Acount- 发表于 2019-3-4 10:53:20

额。。

王道征途 发表于 2019-3-4 12:05:02

666666666666666666

NOVAool 发表于 2019-3-4 13:08:16

加油

楚之 发表于 2019-3-4 14:08:59

我是哪里打错了吗?
0行代码?

小仙女的爸爸 发表于 2019-3-4 14:09:03

1

嘉1417 发表于 2019-3-4 16:28:51

windows下的vc6.0在编写完代码统计这个程序后,如何统计其他的程序代码行数

DrifterCRC 发表于 2019-3-4 17:57:45

看答案啊亲

我爱学语言 发表于 2019-3-4 19:22:54

老师,我写的这个没有错误但是结果不对啊   求解


#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 _finddata_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 _finddata_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 (!strcmp(fa.name, ".") || !strcmp(fa.name, ".."))
                        continue;

                if( fa.attrib == _A_SUBDIR)
                {
                        sprintf(thePath, "%s/%s", path, fa.name);
                        findAllCodes(thePath);
                        findALLDirs(thePath);
            }
      }while (_findnext(handle, &fa) == 0);

      _findclose(handle);
    }

int main()
{
      char path = ".";

      printf("ji suan zhong...\n");

      findAllCodes(path);
      findALLDirs(path);

      printf("mu qian ni zong gong xie le %ld hang dai ma !\n\n",total);
      system("pause");

      return 0;
    }


/小红帽 发表于 2019-3-4 20:50:04

1

你的驼驼 发表于 2019-3-4 20:59:00

看答案

supeng 发表于 2019-3-4 21:15:10

看一下答案

1164335157 发表于 2019-3-4 23:34:37

第十行这个错误是什么

武晴晴 发表于 2019-3-5 08:09:11

1

陨落丶小殇 发表于 2019-3-5 10:57:04

anan

九月枫烬 发表于 2019-3-5 12:58:30

打完了,在函数‘findAllDirs’中:
count_linse.c:(.text+0x210):对‘cloesdir’未定义的引用
collect2: 错误:ld 返回 1
看不懂
页: 251 252 253 254 255 256 257 258 259 260 [261] 262 263 264 265 266 267 268 269 270
查看完整版本: S1E2:第一个程序 | 课后测试题及答案