1
226
22hang you cuowu ei
巴拉巴拉
1
0.它只认识二进制代码
1.机器码
2.编译
3.编译型语言可以直接cpu执行
解释型语言需要将源代码转化为中间代码再给解释器翻译给cpu
4.不行
5.不同的解释器可实现在不同操作系统下文件的执行
6.查表 特定符号对应一个字母
7.亲们趁敌人吃饭时发动进攻
啊啊啊
努力学习天天向上
///
你好,我刚学,我想知道课后作业程序从一开始就是这么编译的,如何到达count-lines
0.机器只能识别二进制0 1的代码
1.机器语言
2.编译
3.解释型语言需要解释器将语言进行翻译
4.能
5.使用解释器
6.使用符号组合来代表实际功能
7.QINMENCHENDiR
{:10_254:}
#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;
}
1
本帖最后由 WITPEN白羽 于 2019-9-4 01:11 编辑
$ gcc cs.c -o cs
cs.c: 在函数‘countLines’中:
cs.c:19: 错误:‘FTLF’未声明(在此函数内第一次使用)
cs.c:19: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其
cs.c:19: 错误:所在的函数内也只报告一次。)
cs.c:19: 错误:‘fp’未声明(在此函数内第一次使用)
cs.c: 在函数‘findAllDirs’中:
cs.c:64: 错误:‘null’未声明(在此函数内第一次使用)
$
这事为什么啊,大佬 ,头文件我都写了啊没有少写
认真做题,积极学习
test
加油,今天是第一天学习
对答案
看一看答案