1111111111111111
查看答案
1
0 二进制
1 机器语言
2 编译
3 编译型一次性编译所有代码,解释型边编译边执行
4 不能
5 安装各自平台适用的解释器即可
6 不知道专有名词
7 亲们
{:5_106:}
感谢分享!
6666
38781
加1
1
#include <stdio.h>
#include <unistd.h>
#include < 啧啧啧>
#include < 字符串.h>
#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;
整数温度:
if ( (fp = fopen(文件名, "r")) == NULL)
{
fprintf(stderr, "无法打开文件: %s\n", 文件名);
返回 0;
}
而 ( (temp = fgetc (fp) ) ! = EOF)
{
if (temp == '\n')
"test2.c" 108L, 1532C 13,1 顶端
1
kanakn
计算机只能读懂特定语言
机器语言
编译
编译型语言在源程序编译后即可在该平台运行,解释型语言在运行期间才编译
不能
主要是通过语言解释器来实现跨平台
由简单的短和长的脉冲及其间隔来表示字母和数字的相互转换
不知道
本帖最后由 Lost_Mi_Yang 于 2023-9-6 08:13 编辑
感谢小甲鱼。
我觉得有两点需要提一下:
1、本次练习中windows系统的示例代码中声明了findALLFiles这个函数,但是后面没有定义它,对应的,后面的findALLDirs这个函数没有和其他函数一起声明,而是声明的同时进行了定义。我想这里应该是您一时疏忽吧,不过不影响代码运行结果,所以我就不去找茬区专门发帖了。
2、即使抄代码的过程中没有错误,最后运行结果也可能不对,因为学生相关的设置可能没有做好(唉)。我使用的是windows平台的VS Code,默认使用UTF-8编码,运行结果是乱码,改成GB 2312就可以输出正常的结果了。
不知道您有没有空刷到这里呢。
答案
ddd
不知道错哪
好的
#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 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)) != -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 main()
{
char path = ".";
printf("计算中...\n");
findAllCodes(path);
findALLDirs(path);
printf("目前你总共写了 %ld 行代码!\n\n", total);
system("pause");
return 0;
}