#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <字符串>
#include <stdlib.h>
#include <sys/stat.h>
#define 最大 256
长总计;
int countLines(const char *filename);
int isCode(const char *filename);
void findAllDirs(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);
返回计数;
}
int isCode(const char *filename)
{
整型长度;
length = strlen(filename);
if (!strcmp(filename + (length - 2), “.c”))
{
返回 1;
}
还
{
返回 0;
}
}
void findAllDirs(const char *path)
{
DIR *dp;
struct dirent *entry;
struct statbuf;
if ((dp = opendir(path)) == NULL)
{
fprintf(stderr, “path %s is error!\n”, path);
返回;
}
chdir(path);
while ((entry = readdir(dp)) != NULL)
{
lstat(entry->d_name, &statbuf);
if (!strcmp(“.”, entry->d_name) || !strcmp(“..”, entry->d_name))
继续;
如果 (S_ISDIR(statbuf.st_mode))
{
findAllDirs(entry->d_name);
}
还
{
if (isCode(entry->d_name))
{
总计 += 计数线(入门级>d_name);
}
}
}
chdir(“..”);
closedir(dp);
}
int main()
{
字符路径 = “.”;
printf(“计算中...\n”);
findAllDirs(path);
printf(“目前你总共写了 %ld 行代码!\n\n”, total);
返回 0;
}
1
1
查看参考答案
已完成训练
学习c语言第一天,打卡{:9_228:}
想问一下,为什么我的第一个代码不给计算结果呢,是哪里出问题了吗?
来看答案啦
怎么翻译成中文?
0. 为什么我们说计算机其实是“二傻子”?
只懂0和1(二进制)
1. CPU 唯一认识的语言是什么语言?
机器语言
2. C 语言编写的源代码转换为汇编语言的过程叫什么?
编译
3. 编译型语言和解释型语言的本质区别是什么?
一个一行代码编译一次,一个整个代码一起编译
4. 在 Linux 系统上用 C 语言编译的可执行程序,是否能在 Windows 系统上执行?
大部分能
5. 解释型编程语言是如何实现跨平台的?
通过转化为字节码
6. 莫斯密码的原理其实是什么?
查表
7. 视频中小甲鱼“故弄玄虚”的那段密文还原后是什么内容(中文)?
I don't know SOS
{:5_102:}
build succeed了
1
查看答案
答案
查看参考答案
求看
1.二进制
2、解码
3.解释性语言需要解释器
4.可以
5.通过源代码通过对应的解释器解码
6.对应表查询
附图
查看答案
计算中...
目前你总共写了 0 行代码!