保罗贝尔 发表于 2021-3-17 08:14:52

完成了0行程序?

cupin 发表于 2021-3-17 09:27:49

0001011101101

guidong 发表于 2021-3-17 09:50:43

查看答案、、、

cupin 发表于 2021-3-17 09:58:40

我复制之后,没有错误,运行显示的是“按任意键继续”这个咋整?

一粒尘埃233 发表于 2021-3-17 10:10:10

人类的本质就是乱码~{:10_266:}

liukeshun 发表于 2021-3-17 10:23:52

dana

想要学好c 发表于 2021-3-17 10:28:08

加油

13132751178 发表于 2021-3-17 10:39:36

齐语 发表于 2021-3-17 10:53:28

祝楼主头发永不掉落

iHIT 发表于 2021-3-17 11:17:20

为什么在windows下无法编译通过

[little] 发表于 2021-3-17 11:39:40

daan

zigua 发表于 2021-3-17 11:46:31

1

我要学习c 发表于 2021-3-17 11:47:59

答案

memissme 发表于 2021-3-17 13:22:57

学习一下解释型编程语言是如何实现跨平台的?

向往1 发表于 2021-3-17 13:24:59

33

Mr.焘 发表于 2021-3-17 13:28:53

1

黒色紫罗兰 发表于 2021-3-17 13:42:16


#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)) != -lL)
        {
                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)) == -lL)
        {
                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("目前你总共写了 %1d 行代码! \n\n", total);
        system("pause");
       
        return 0;
}
这哪错了啊

黒色紫罗兰 发表于 2021-3-17 13:48:19

目前你总共写了0行代码。。。。。

bangec 发表于 2021-3-17 14:23:55

00000000

17560848834 发表于 2021-3-17 14:29:14

1
页: 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 [1116] 1117 1118 1119 1120 1121 1122 1123 1124 1125
查看完整版本: S1E2:第一个程序 | 课后测试题及答案