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

网站备案的意思dw个人网站制作模板

网站备案的意思,dw个人网站制作模板,口碑营销案例ppt,百度提交网站收录入口要求#xff1a; (1)可以实现下列几条命令 dir 列文件目录 create 创建文件 delete 删除文件 read 读文件 write 写文件 (2)列目录时要列出文件名、存取权限#xff08;八进制#xff09;、文件长度、时间#xff08;创建时间#xff0c;修改时间以及…要求 (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://www.hkea.cn/news/14532529/

相关文章:

  • 儿童网站模板用表格做网站教程
  • 营销型企业网站群策略78模板网免费模板
  • 做企业网站需要哪些网站服务器如何搭建
  • 中国制造网内贸站网站建设如何存数据
  • 大气产品展示网站源码免费做优化的网站
  • 长沙做网站有哪些做家教网站
  • 樟树有哪几个网站做爆药库wordpress对比discuz
  • 网站地图有哪些网址网站制作客户资料
  • 开封网站建设优化东莞长安网站优化
  • 天津网站建设招聘网站公司郑州
  • 2022热点新闻事件厦门网站流量优化价格
  • 网站结构及内容建设策略站长 网站对比
  • frontpage导入网站关于进一步加强门户网站建设
  • 腾讯微博做网站外链步骤工程建设室内涂料招投标网站
  • 网站建设中 动画做网站客户尾款老不给怎么办
  • 许昌 网站建设网站推广的方法是什么
  • ps制作网站首页教程网络营销方法有几种类型
  • 济南集团网站建设流程网站建设销售渠道
  • 口碑好网站建设定制泡泡资源网
  • 如何在自己建设的网站上发表文章编程教学
  • 北京网站设计方案今天重庆新闻
  • 阿里巴巴吧国际网站怎么做php推送示例wordpress
  • 网站app建设图片素材甘肃省第九建设集团网站
  • 高德地图看不了国外厦门关键词排名seo
  • 帝国cms下载类网站怎么做买东西的网站
  • ie浏览器官方网址入口seo推广介绍
  • 上海网站建设最好的公司排名旅游搜索网站开发
  • 网站开发流程简述龙岗网站改版
  • 阿里云模板建站怎么样php网站开发模式有哪些
  • apache怎么配置网站唐山房地产网站建设