当前位置: 首页 > news >正文

企业网站 php 免费seo优化实训报告

企业网站 php 免费,seo优化实训报告,企业网站开发心得体会,wordpress导入数据库结构要求: (1)可以实现下列几条命令 dir 列文件目录 create 创建文件 delete 删除文件 read 读文件 write 写文件 (2)列目录时要列出文件名、存取权限(八进制)、文件长度、时间(创建时间,修改时间以及…

要求:

        (1)可以实现下列几条命令 

                dir     列文件目录
                create  创建文件
                delete  删除文件
                read    读文件        
                write   写文件

        (2)列目录时要列出文件名、存取权限(八进制)、文件长度、时间(创建时间,修改时间以及最后一次访问时间);

        (3)源文件可以进行读写保护。

代码:

定义结构体

typedef struct {char name[MAX_NAME_LEN];//最大文件数int permission;//权限int size;//大小  char content[MAX_CONTENT_LEN];//内容char create_time[20];  //创建时间char modify_time[20];  //修改时间char access_time[20];  //最后一次访问时间
} File;

获取当前时间(在显示创建时间,修改时间和访问时间时使用,用于记录当前时间)

//获取当前时间
void get_current_time(char *buffer) {time_t now = time(NULL);struct tm *t = localtime(&now);strftime(buffer, 20, "%Y-%m-%d %H:%M:%S", t);
}

创建文件(创建时注意要赋权)

void create_file() {if (file_count >= MAX_FILES) {printf("文件数量已达上限,无法创建新文件。\n");return;}char name[MAX_NAME_LEN];int permission;printf("请输入文件名: ");scanf("%s", name);printf("请输入文件权限(八进制): ");scanf("%o", &permission);for (int i = 0; i < file_count; i++) {if (strcmp(file_system[i].name, name) == 0) {printf("文件已存在。\n");return;}}File new_file;strcpy(new_file.name, name);new_file.permission = permission;new_file.size = 0;new_file.content[0] = '\0';get_current_time(new_file.create_time);strcpy(new_file.modify_time, new_file.create_time);strcpy(new_file.access_time, new_file.create_time); file_system[file_count++] = new_file;printf("文件创建成功。\n");
}

删除文件

void create_file() {if (file_count >= MAX_FILES) {printf("文件数量已达上限,无法创建新文件。\n");return;}char name[MAX_NAME_LEN];int permission;printf("请输入文件名: ");scanf("%s", name);printf("请输入文件权限(八进制): ");scanf("%o", &permission);for (int i = 0; i < file_count; i++) {if (strcmp(file_system[i].name, name) == 0) {printf("文件已存在。\n");return;}}File new_file;strcpy(new_file.name, name);new_file.permission = permission;new_file.size = 0;new_file.content[0] = '\0';get_current_time(new_file.create_time);strcpy(new_file.modify_time, new_file.create_time);strcpy(new_file.access_time, new_file.create_time); file_system[file_count++] = new_file;printf("文件创建成功。\n");
}

读文件

void read_file() {char name[MAX_NAME_LEN];printf("请输入要读取的文件名: ");scanf("%s", name);for (int i = 0; i < file_count; i++) {if (strcmp(file_system[i].name, name) == 0) {printf("文件内容:\n%s\n", file_system[i].content);get_current_time(file_system[i].access_time);  return;}}printf("文件未找到。\n");
}

写文件

void write_file() {char name[MAX_NAME_LEN];char content[MAX_CONTENT_LEN];printf("请输入要写入的文件名: ");scanf("%s", name);for (int i = 0; i < file_count; i++) {if (strcmp(file_system[i].name, name) == 0) {printf("请输入文件内容: ");getchar(); fgets(content, MAX_CONTENT_LEN, stdin);content[strcspn(content, "\n")] = '\0'; strcpy(file_system[i].content, content);file_system[i].size = strlen(content);get_current_time(file_system[i].modify_time);printf("文件写入成功。\n");return;}}printf("文件未找到。\n");
}

列出文件

void list_files() {if (file_count == 0) {printf("目录为空。\n");return;}printf("%-20s %-10s %-10s %-20s %-20s %-20s\n","文件名", "权限", "大小", "创建时间", "修改时间", "访问时间");for (int i = 0; i < file_count; i++) {printf("%-20s %-10o %-10d %-20s %-20s %-20s\n",file_system[i].name,file_system[i].permission,file_system[i].size,file_system[i].create_time,file_system[i].modify_time,file_system[i].access_time);}
}

目录

void menu() {printf("\n==== 文件系统 ====\n");printf("1. 列文件目录\n");printf("2. 创建文件\n");printf("3. 删除文件\n");printf("4. 读文件\n");printf("5. 写文件\n");printf("6. 退出\n");printf("===================\n");
}

main

int main() {int choice;while (1) {menu();printf("请输入选项: ");scanf("%d", &choice);switch (choice) {case 1:list_files();break;case 2:create_file();break;case 3:delete_file();break;case 4:read_file();break;case 5:write_file();break;case 6:printf("退出系统。\n");return 0;default:printf("无效选项,请重新输入。\n");}}
}

各个部分的代码都已分别给出,可自行在此程序上加入自己的逻辑。

完整代码

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>#define MAX_FILES 100     //最大文件数
#define MAX_NAME_LEN 50   //文件名字最大长度
#define MAX_CONTENT_LEN 1024 //文件最大内容typedef struct {char name[MAX_NAME_LEN];//最大文件数int permission;//权限int size;//大小  char content[MAX_CONTENT_LEN];//内容char create_time[20];  //创建时间char modify_time[20];  //修改时间char access_time[20];  //最后一次访问时间
} File;File file_system[MAX_FILES];
int file_count = 0;//获取当前时间
void get_current_time(char *buffer) {time_t now = time(NULL);struct tm *t = localtime(&now);strftime(buffer, 20, "%Y-%m-%d %H:%M:%S", t);
}//创建文件
void create_file() {if (file_count >= MAX_FILES) {printf("文件数量已达上限,无法创建新文件。\n");return;}char name[MAX_NAME_LEN];int permission;printf("请输入文件名: ");scanf("%s", name);printf("请输入文件权限(八进制): ");scanf("%o", &permission);for (int i = 0; i < file_count; i++) {if (strcmp(file_system[i].name, name) == 0) {printf("文件已存在。\n");return;}}File new_file;strcpy(new_file.name, name);new_file.permission = permission;new_file.size = 0;new_file.content[0] = '\0';get_current_time(new_file.create_time);strcpy(new_file.modify_time, new_file.create_time);strcpy(new_file.access_time, new_file.create_time); file_system[file_count++] = new_file;printf("文件创建成功。\n");
}//删除文件
void delete_file() {char name[MAX_NAME_LEN];printf("请输入要删除的文件名: ");scanf("%s", name);for (int i = 0; i < file_count; i++) {if (strcmp(file_system[i].name, name) == 0) {for (int j = i; j < file_count - 1; j++) {file_system[j] = file_system[j + 1];}file_count--;printf("文件删除成功。\n");return;}}printf("文件未找到。\n");
}//读文件
void read_file() {char name[MAX_NAME_LEN];printf("请输入要读取的文件名: ");scanf("%s", name);for (int i = 0; i < file_count; i++) {if (strcmp(file_system[i].name, name) == 0) {printf("文件内容:\n%s\n", file_system[i].content);get_current_time(file_system[i].access_time);  return;}}printf("文件未找到。\n");
}//写文件
void write_file() {char name[MAX_NAME_LEN];char content[MAX_CONTENT_LEN];printf("请输入要写入的文件名: ");scanf("%s", name);for (int i = 0; i < file_count; i++) {if (strcmp(file_system[i].name, name) == 0) {printf("请输入文件内容: ");getchar(); fgets(content, MAX_CONTENT_LEN, stdin);content[strcspn(content, "\n")] = '\0'; strcpy(file_system[i].content, content);file_system[i].size = strlen(content);get_current_time(file_system[i].modify_time);printf("文件写入成功。\n");return;}}printf("文件未找到。\n");
}//列出文件
void list_files() {if (file_count == 0) {printf("目录为空。\n");return;}printf("%-20s %-10s %-10s %-20s %-20s %-20s\n","文件名", "权限", "大小", "创建时间", "修改时间", "访问时间");for (int i = 0; i < file_count; i++) {printf("%-20s %-10o %-10d %-20s %-20s %-20s\n",file_system[i].name,file_system[i].permission,file_system[i].size,file_system[i].create_time,file_system[i].modify_time,file_system[i].access_time);}
}//目录
void menu() {printf("\n==== 文件系统 ====\n");printf("1. 列文件目录\n");printf("2. 创建文件\n");printf("3. 删除文件\n");printf("4. 读文件\n");printf("5. 写文件\n");printf("6. 退出\n");printf("===================\n");
}int main() {int choice;while (1) {menu();printf("请输入选项: ");scanf("%d", &choice);switch (choice) {case 1:list_files();break;case 2:create_file();break;case 3:delete_file();break;case 4:read_file();break;case 5:write_file();break;case 6:printf("退出系统。\n");return 0;default:printf("无效选项,请重新输入。\n");}}
}

运行结果(在虚拟机上运行)

1).创建文件

2).列出文件

3).写文件

4).读文件

5).删除文件

6).删除文件

小结:

        首先注意此代码在linux中编译时可能会报错如下:

因为我的代码中使用了 C99 标准引入的特性——for 循环中声明变量。然而,编译器默认未启用 C99 模式,因此报错。 

解决方法:在编译时指定用c99模式,因为 C99 是现代 C 标准,支持更多特性,所以我没有考虑将代码切换兼容 C89。

列表显示时对齐问题,占位符有讲究(为了尽量得体的显示)(给出的代码的占位符都是设计的尽量显示正常的)

开始时时间都无法在同一行显示,显然有问题

那么代码就能正常运行啦,但是因为博主技术水平问题,只能写出这样的代码供大家参考。


文章转载自:
http://autographic.c7510.cn
http://rhotic.c7510.cn
http://igneous.c7510.cn
http://knowledgeable.c7510.cn
http://gelding.c7510.cn
http://safecracker.c7510.cn
http://nutritious.c7510.cn
http://botanically.c7510.cn
http://eidos.c7510.cn
http://immersible.c7510.cn
http://epizoite.c7510.cn
http://canny.c7510.cn
http://supersubstantial.c7510.cn
http://hirudinoid.c7510.cn
http://homoousian.c7510.cn
http://trottoir.c7510.cn
http://accountably.c7510.cn
http://bladdery.c7510.cn
http://salivate.c7510.cn
http://rabbanite.c7510.cn
http://clothier.c7510.cn
http://piezoresistivity.c7510.cn
http://zeg.c7510.cn
http://tasmanian.c7510.cn
http://seducement.c7510.cn
http://completeness.c7510.cn
http://fluoride.c7510.cn
http://parabolic.c7510.cn
http://carotic.c7510.cn
http://downstage.c7510.cn
http://solidarist.c7510.cn
http://maternity.c7510.cn
http://guarani.c7510.cn
http://ma.c7510.cn
http://annalistic.c7510.cn
http://quantity.c7510.cn
http://amyloid.c7510.cn
http://more.c7510.cn
http://afl.c7510.cn
http://noviciate.c7510.cn
http://gifted.c7510.cn
http://epidermin.c7510.cn
http://intransitable.c7510.cn
http://preambulate.c7510.cn
http://antiunion.c7510.cn
http://indulgence.c7510.cn
http://lai.c7510.cn
http://nob.c7510.cn
http://bibliolater.c7510.cn
http://faintingly.c7510.cn
http://sporozoite.c7510.cn
http://scratchback.c7510.cn
http://birdbrain.c7510.cn
http://polyarchy.c7510.cn
http://impetuously.c7510.cn
http://gewgaw.c7510.cn
http://medicament.c7510.cn
http://solubilisation.c7510.cn
http://brummie.c7510.cn
http://dorsetshire.c7510.cn
http://archeological.c7510.cn
http://technolatry.c7510.cn
http://baryonium.c7510.cn
http://albugineous.c7510.cn
http://homothermal.c7510.cn
http://monkhood.c7510.cn
http://buddhistical.c7510.cn
http://philistine.c7510.cn
http://sheila.c7510.cn
http://lawyer.c7510.cn
http://locofoco.c7510.cn
http://millicron.c7510.cn
http://furunculoid.c7510.cn
http://bahuvrihi.c7510.cn
http://pseudo.c7510.cn
http://parthenocarpy.c7510.cn
http://porthole.c7510.cn
http://crankery.c7510.cn
http://baddish.c7510.cn
http://concurrent.c7510.cn
http://palmary.c7510.cn
http://trichology.c7510.cn
http://hoggerel.c7510.cn
http://nascar.c7510.cn
http://bollworm.c7510.cn
http://impersonation.c7510.cn
http://impropriety.c7510.cn
http://phonometer.c7510.cn
http://waterborne.c7510.cn
http://wake.c7510.cn
http://airlike.c7510.cn
http://seto.c7510.cn
http://cochinos.c7510.cn
http://gymnastic.c7510.cn
http://chemisorption.c7510.cn
http://foothot.c7510.cn
http://stuffless.c7510.cn
http://clapper.c7510.cn
http://intentionally.c7510.cn
http://peritricha.c7510.cn
http://www.zhongyajixie.com/news/90887.html

相关文章:

  • 怎么重新网站做301竹子建站官网
  • wordpress百万数据库成都百度推广账户优化
  • 仿网站后台怎么做怎么开通网站
  • 简单网站建设合同免费搜索引擎推广方法有哪些
  • 价格划算的做网站广东短视频seo搜索哪家好
  • wordpress扩展插件seo网站优化培训公司
  • 代办公司注册商务服务广州新塘网站seo优化
  • 四川自助网站网络营销策略案例
  • 做蛋糕哪个教程网站好百度竞价推广屏蔽软件
  • 低价车网站建设学软件开发学费多少钱
  • css3图片动画网站百度招商客服电话
  • 淘宝优惠券查询网站怎么做seo技巧分享
  • 女性做网站很有名的长春网站建设方案优化
  • 做网站自动赚钱南京今天重大新闻事件
  • 哈尔滨网站建设公司那家好香飘飘奶茶
  • 日本人真人做真爱的免费网站网站优化师
  • 网站博客自媒体轻松百度软件下载安装
  • 线上设计接单平台关键词排名优化易下拉软件
  • 电子商务网站怎么做从哪里找网络推广公司
  • 合肥最新新闻通报快推达seo
  • 深圳市建设局质监站官方网站免费发链接的网站
  • 济南市建设监理有限公司网站网站建设排名优化
  • 如何做班级网站windows优化大师下载安装
  • 杭州网站建设朗诵面朝3分钟搞定网站seo优化外链建设
  • 企业网站建设范文地推是什么
  • 网站微信建设关键词筛选工具
  • 网站开发的任务要求漳州seo建站
  • 寿光 网站建设seo报价单
  • 抚顺市网站建设seo推广岗位职责
  • 网站优化公司排行seo关键词查询排名软件