d,an
计算机只认识数字
机器语言
编译
前者是面向过程的语言,后者是面向对象的语言
能
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#define MAX 256
long total;
int countLines(const char *filename);
int isCode(const char *filename);
void findAllDirs(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;
}
int isCode(const char *filename)
{
int length;
length = strlen(filename);
if (!strcmp(filename + (length - 2), ".c"))
{
return 1;
}
else
{
return 0;
}
}
void findAllDirs(const char *path)
{
DIR *dp;
struct dirent *entry;
struct stat statbuf;
if ((dp = opendir(path)) == NULL)
{
fprintf(stderr, "The path %s is wrong!\n", path);
return;
}
chdir(path);
while ((entry = readdir(dp)) != NULL)
{
lstat(entry->d_name, &statbuf);
if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name))
continue;
if (S_ISDIR(statbuf.st_mode))
{
findAllDirs(entry->d_name);
}
else
{
if (isCode(entry->d_name))
{
total += countLines(entry->d_name);
}
}
}
chdir("..");
closedir(dp);
}
int main()
{
char path = ".";
printf("计算中...\n");
findAllDirs(path);
printf("目前你总共写了 %ld 行代码!\n\n", total);
return 0;
}
唉
计算中
(⊙o⊙)
我要答案
不看答案真不会,老说我1楼缺了
1
因为计算机只能执行
亲们趁敌人吃饭时发动进攻
答案
我这边编译的时候一堆错误{:5_90:}
1
膜拜大佬
0.因为CPU只懂得二进制的0和1。
1.机器语言
2.编译
3.编译型语言最终翻译成机器语言,解释型语言不直接编译成机器语言。
4.可以
5.解释型语言将源代码转换成中间代码,然后发送给解释器,由解释器逐句翻译给CPU来执行。
6.查表
7.亲们趁敌人吃饭时发动进攻
0.他只能识别二进制码
1.机器语言
2.编译
3.
4.可以
5.
6.查找密码表
7.qinmenchendirenchifanshifadongjingong
亲们趁敌人吃饭时发动进攻
0
第一次照着代码抄完之后,出了好多错。检查第一遍之后,运行结果不对。等检查过两三次,发现了几处编译器没有指出的语法或者其他错误,等自己觉得和答案代码一模一样之后,运行结果还是不对。
666