不忘初心8 发表于 2022-3-10 15:09:28

刚开始学,看的一脸懵逼的

浩哥要学C语言 发表于 2022-3-10 15:28:38


#include <io.h>
#include <直接>
#include <stdio.h>
#include <stdlib.h>
#include <字符串>

#define 最大 256

长总计;

int countlines (const char *filename);
void findAllCodes (const char *path);
void findALLFiles (const char *path);

int countLines (const char *filename)
{
文件 *fp;
整数计数 = 0;
int temp;

if( (fp = fopen (filename,"r") )== NULL
         {
fprintf(stderr, "无法打开文件: %s\n",文件名) ;
返回 0;
               }
               
while((temp = fgetc (fp) )! = EOF)
         {
if(temp == '\n' )
               {
计数++;
                                  }
               }
               
fclose(fp) ;

返回计数;
}

void findAllCodes (const char *path)
{
结构_finddata_t法;
长柄;
char thePath,target;

strcpy (thePath,path) ;
if (handle = _findfirst (strcat (thePath, "/*.c") , &fa) )! = -1L
         {

                {
sprintf (target,"%s/%s",path,fa.name) ;
总计 += 计数线 (目标) ;
}while (_findnext (handle,&fa) == 0) ;
               }

_findclose (手柄) ;
}

void findALLDirs (const char *path)
{
结构_finddata_t法;
长柄;
char thePath;

strcpy (thePath,path) ;
if ( (handle = _findfirst (strcat (thepath,"/*") ,%fa) ) == -1L)
      {
fprintf (stderr,"The path %s is error! \n", path) ;
返回;
                  }
                  
做                  
          {
if(! strcmp (fa.name,".")|| ! strcmp (fa.name, "..") )
继续;

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

_findclose (手柄) ;
}

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

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

findAllCodes (path) ;
findALLDirs (path) ;

printf ("目前你总共写了 %1d 行代码! \n\n",total);
系统 ("暂停") ;

返回 0;
}

1844034822 发表于 2022-3-10 15:55:48

up牛牛牛

ypypypckd123 发表于 2022-3-10 16:49:52

1

yukiamo 发表于 2022-3-10 16:54:55

1

lidetun 发表于 2022-3-10 17:38:51

dd

zerovxv 发表于 2022-3-10 19:19:25

let me sese

accident6663 发表于 2022-3-10 19:44:41

1

15970072575 发表于 2022-3-10 19:56:57

对对答案

yxxaa 发表于 2022-3-10 20:34:56

haoye

yblq007 发表于 2022-3-10 20:56:55

102

zh950813 发表于 2022-3-10 21:17:18

0 因为计算机只能事业0和1

1 机器语言 汇编语言

2 编译

3

4 可以

5

6 对表

乔风飞 发表于 2022-3-10 21:33:20

为啥windows代码编译后是0行,把代码复制过去结果也是0行,不解{:10_243:}

yunzhe1995 发表于 2022-3-10 22:42:41

6666666666666666666666666666666

karupisu 发表于 2022-3-10 22:48:55

看看答案

1fish 发表于 2022-3-10 23:46:33

课程还蛮有趣

c@ljf 发表于 2022-3-11 08:40:01

1

Mr.二 发表于 2022-3-11 09:13:43

只能识别0、1代码;机器语言;编译;可以;在另一平台上装个解释器

eightN 发表于 2022-3-11 09:19:44

6666666666666666666666

翊cheng 发表于 2022-3-11 10:54:00

,
页: 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 [1589] 1590 1591 1592 1593 1594 1595 1596 1597 1598
查看完整版本: S1E2:第一个程序 | 课后测试题及答案