小小怪下士丶 发表于 2022-6-14 09:26:23

llcllcllc 发表于 2022-6-14 09:27:06

1

小小怪下士丶 发表于 2022-6-14 09:27:20

结城 发表于 2022-6-14 12:19:56

让我康康

欧根亲王 发表于 2022-6-14 15:16:52

回复

kyrie.lin 发表于 2022-6-14 16:20:11

查看参考答案

1149380706 发表于 2022-6-14 17:21:13

1

超级斌 发表于 2022-6-14 18:43:15

1

可爱小躲 发表于 2022-6-14 23:39:40

2022/6/14 第一次看课打卡~

deiou 发表于 2022-6-15 09:19:54

运行时权限不够怎么解决

hacker-007 发表于 2022-6-15 10:21:02

1

小琳不是云 发表于 2022-6-15 10:46:15


#include<io.h>
#include<direct.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX256

long total;
//ok
int coutLines(const char *filename);
void fileAllCodes(const char *path);
void fileALLFiles(const char *path);

int coutLines(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;
        }
        //yes
        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);
}
//yes
void findALLDirs(const char *path)
{
   struct _finddata_t fa;
        long handle;
        char thePath;
        //yes
        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;
                //yes
               
                if(fa.attrib == _A_SUBDIR)
                {
                        sprintf(thePath,"%s/%s",path,fa.name);
                        findAllCodes(thePath);
                        findALLDirs(thePath);
                }
        }while(_findnext(handle,&fa)==0);
       
        _findclose(handle);
       
        }
        //yes
        int main(){
                char path =".";
                printf("计算中...\n");
                findAllCodes(path);
                findALLDirs(path);
               
                printf("目前你总共写了%ld 行代码!\n\n",total);
                system("pause");
                return 0;
        }

目前你已经写了99行代码

15846762641 发表于 2022-6-15 11:29:04

22

ZH-x 发表于 2022-6-15 15:15:50

查看参考答案

ANGEL04 发表于 2022-6-15 15:37:25

iOS上的c语言怎么会报错啊

ANGEL04 发表于 2022-6-15 15:38:32

iOS端的c语言程序直接报错了

shocheng 发表于 2022-6-15 16:10:40

shocheng

qhxyz 发表于 2022-6-15 16:11:54

1

香槟树下 发表于 2022-6-15 16:29:02

亲们,陈地人拆凡是发东仅共

1870054561 发表于 2022-6-15 16:44:28

看答案
页: 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 [1648] 1649 1650 1651 1652 1653 1654 1655 1656 1657
查看完整版本: S1E2:第一个程序 | 课后测试题及答案