秃头小萌新 发表于 2023-9-7 23:52:57

我只有计算中没有显示多少行代码

2594856470 发表于 2023-9-8 03:23:38


#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 dile:%s\n",filename);
return 0;
       }
while((temp = fgetc(fp)) != EOF)

                {
if (temp == '\n')
                                {
count++;
                                }
               }
fclosr(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 mainn()
{
char path = ".";

printf("计算中...\n");

findALLCodes(path);
findALLDirs(path);

printf("目前你总共写了%ld 行代码!\n\n", total);
system("pause");

return 0;
   }

为啥运行不了,求教教

flyingmario 发表于 2023-9-8 08:18:43

0.只能识别0和1的二进制
1.机器语言
2.编译
3.编译型语言被编译成机器语言后CPU即可执行,解释型语言每次运行前需要解释器解释
4.可以
5.运行前解释
6.不同字符对应不同编码
7.QINMEN CHEND IRENC HIFAN SHIF ADONG JINGO NG
亲们趁敌人吃饭时发动进攻

mark0dda 发表于 2023-9-8 09:12:53

1

exy 发表于 2023-9-8 09:21:34

答案

最可爱的雪雪 发表于 2023-9-8 09:42:22

课后测试题及答案

zsh050509 发表于 2023-9-8 10:59:07

11

1452775909 发表于 2023-9-8 14:10:24

111111

AUC 发表于 2023-9-8 14:16:52

您好

悠哉的木头 发表于 2023-9-8 16:30:23

编译了三遍啊三遍,终于没报错了

IZuNa 发表于 2023-9-8 18:09:24

是是有一个程序正在运行了,可能是写完之后拿答案对照时不小心把答案运行了,但是原来的那个怎么关掉呢?

cv5137 发表于 2023-9-8 20:16:30

看看答案

shark.c 发表于 2023-9-8 20:27:42

0. y因为计算机只能识别机械语言。我们想要让计算机了解我们的意图需要将我们的语言转化成机械语言它才能看懂执行。
1.汇编语言
2. 编译
3.编译型语言不需要编译器的伴随,解释型语言需要编译器的伴随。
4.能
5.将程序拿到其他平台上然后再下载所需要的解释器即可。
6.莫斯密码采用的是短脉冲和长脉冲的形式,通过它们的组合,可以产生字母或数字。
7.QINMENCHENDIRENDIRE

玊与和 发表于 2023-9-8 21:06:59

只能识别0和1

鱼米露 发表于 2023-9-8 21:29:03

qqq

1984702430 发表于 2023-9-8 21:49:33


tuya 发表于 2023-9-8 22:33:56

QINMENCHENDIRENCHIFANSHIFANDONGJNGONG

15138332301 发表于 2023-9-9 10:40:01

66

quietshj 发表于 2023-9-9 14:57:46

查看参考答案

w957391512 发表于 2023-9-9 16:56:33

已完成
页: 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 [1941] 1942 1943 1944 1945 1946 1947 1948 1949 1950
查看完整版本: S1E2:第一个程序 | 课后测试题及答案