0.计算机只懂二进制
1.机器码
2.编译
3.是否需要解释器
4.可以
5.通过解释器
6.查表,解码
7
回复
111
1
我来了,鱼
66
本帖最后由 Tiehanhank 于 2020-4-22 12:08 编辑
#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;
}
哪里错了呜呜呜
结果如下:
计算中......
The path . is wrong!
The path s1e2 is wrong!
Can not open the file: count_lines.c
Can not open the file: count_lines.c
The path .DS_Store is wrong!
The path s1e2 is wrong!
The path count_lines is wrong!
The path count_lines.c is wrong!
The path a.out is wrong!
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
Can not open the file: count_lines.c
目前你总共写了 0 行代码!
查看
#include<io.h>
#include<direct.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 256
long total;
int countlines(const char *fliename);
void findallcodes(const char *path);
void findallfiles(const char *parth);
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+=countlinrs(target);
}while(_findnext(handle,&fa)==0)
}
}
void findalldirs(cont char *path)
{
struct_finddata_t fa;
long handle;
char thepath;
strcpy(thepath,path);
if((handle=_findfirst(strcat(thepath,"/*"),&fa))=-1L)
{
fprintf
}
do
{
if(!strcmp(fa.name,".")||!strcmp(fa.name,".."))
continue;
if(fs.attri==_A_SUBDIR)
{
sprintf(thepath,"%s/%s",path,fa.name);
findallcodes(thepath);
findalldirs(thepath);
}
}whule(_findclose(handle,&fa)==0);
_findclose(handle);
}
int main9
{
char path=".";
printf("计算中...\n");
findallcodes(path);
findalldirs(path);
printf("目前你总共写了%ld行代码!\n\n",total) ;
system("pasue");
return 0;
}
查看答案
0、因为计算机只能读懂0和1
1、机器语言
2、编译
3、编译型语言直接编译比较灵活、解释型语言还需要解释器
4、能
5、解释型编程语言执行时需要解释器
6、原理是编译,将密码按照表翻译成能读懂的语言
7、
修改
0.只认识二进制
1.机器语言
2.编译
3.解释型语言可跨平台
4.不能
5.例如Java就有jvm包可实现跨平台
6.二进制码
9999999999
109行代码
唉
看看答案
0,
1,机器语言
2,编译
3,能否直接编译成机器码
4,不能
5,将源码转换成中间代码,然后发送给解释器,由解释器逐句翻译给 CPU
6,查表
7,亲们,趁敌人吃饭时发动进攻
0. 因为计算机只认识二进制代码
1. 编程语言
2. 编译
3. 解释型语言需要解释器,编译型语言不需要
4. 是
5. 需要解释器
6. 查表