JDFMCC 发表于 2021-9-6 16:36:19

您好,在我编译结束后在第38行出现了这样的问题
48        38        D:\c语言学习\第一节课\未命名3.cpp        'thePath' was not declared in this scope
我找了很久没有发现问题,望解答

Asunmorning 发表于 2021-9-6 16:58:24

对下答案

zhengqwer 发表于 2021-9-6 17:19:50

sss

不愿秃头胡少年 发表于 2021-9-6 19:43:47

qinmen
chend
irenc
hifan
shif
adong
jingo
ng

不愿秃头胡少年 发表于 2021-9-6 19:48:01


#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
long total;

int countlines(const char *filename);
#include <string.h>

#define MAX 256

void findAllCodes(const char *path);
void finfALLFiles(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 += coutlines(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("计算中。。、n");
       
       findAllCodes(path);
       findALLDirs(path);
       
       printf("目前你总共写了 %ld 行代码! \n\n", total);
       system("pause");
       
       return 0;
       
}



我这个有啥毛病呢

zengweiy 发表于 2021-9-6 19:53:23

1

言辞. 发表于 2021-9-6 20:19:37

查看参考答案

柴干 发表于 2021-9-6 20:31:33

1

小陈小陈想进云 发表于 2021-9-6 20:34:34

很好很好

东吴a 发表于 2021-9-6 21:09:05

晚上好!

灰渡w 发表于 2021-9-6 22:02:08

hello world

1024jonas 发表于 2021-9-6 22:27:25

我要学习!

cyy0722 发表于 2021-9-6 22:32:44

6

xqli 发表于 2021-9-6 23:18:54

C:\Users\xql\Desktop\ccccc\p2\collect2.exe        ld returned 1 exit status
一直是此报错哈哈哈。。用文本对比了下,找不出哪儿码错了

0三千繁华0 发表于 2021-9-7 00:10:50

0因为只懂二进制0和1
1机器码也叫机器语言
2叫做编译
3编译型语言CUP可以直接读懂执行
解释型语言要通过解释器CUP才可以读懂执行
4不能把
5把源代码编写成中间码只有别的电脑有解释器就可以跨平台使用
6.查表
7.亲们趁着敌人吃饭时间发动进攻

wangphilip0320 发表于 2021-9-7 08:25:58

求答案

Nvture 发表于 2021-9-7 09:42:19

..

peteryh 发表于 2021-9-7 10:14:33

kankan

ununl 发表于 2021-9-7 10:40:48

look

ljy236 发表于 2021-9-7 10:42:40

菜鸟新手,想要习题答案
页: 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 [1353] 1354 1355 1356 1357 1358 1359 1360 1361 1362
查看完整版本: S1E2:第一个程序 | 课后测试题及答案