20230411

news/2024/10/18 12:24:37/

1.使用readdir来将目录中的链接文件显示出来

2.写入到一个文件内部

3.将文件中的内容显示到屏幕

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>int main(int argc, const char *argv[])
{DIR *dp;struct dirent *dt;int FileNum = 0 ;FILE *fp_out = NULL;char ch ;fp_out = fopen(argv[2],"w+");if(fp_out == NULL){perror("Fail to fp_out");}dp = opendir(argv[1]);if(dp == NULL){perror("Fail to opendir");return -1;}while(1){dt = readdir(dp);if(dt == NULL){break;}if(dt->d_type == DT_LNK ){fprintf(fp_out,"%s \n",dt->d_name);FileNum++;printf("第%d个链接文件: %s\n",FileNum,dt->d_name);}}fseek(fp_out,0,SEEK_SET);while(fscanf(fp_out,"%c",&ch) != EOF){printf("%c",ch);ch = 0;}fclose(fp_out);if(closedir(dp) < 0){perror("Fail to closedir");return -1;}printf("总文件个数: %d\n",FileNum);return 0;
}


http://www.ppmy.cn/news/277035.html

相关文章

20230113

听了几个人的年会总结&#xff0c;做一下归纳 直观上看&#xff0c;个人欠缺对着一页ppt进行流利表达阐述的能力。 原因1项目管理层面 自己做的项目比较散&#xff0c;也缺乏项目管理规划经验。做的一体化虽然排期都是自己排的&#xff0c;但当时缺乏对人员安排的底气和项目完成…

20230103

1. 如何定义一个存储Book类型对象的数组 数据类型[ ] 数组名 new 数据类型 [数组长度]Book[] arr new Book[10] 2.将一个Book类型对象&#xff0c;存储到数组第二个元素 Book book new Book();arr[1] book; 3.如何快捷生成构造方法 &#xff08;Eclipse中&#xff09; ① …

错误: 80004023

检索 COM 类工厂中 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件时失败&#xff0c;原因是出现以下错误: 80004023。 winform开发excel文档&#xff0c;安装到客户机上发生了这样的错误&#xff0c;网上查了很多没找到解决办法 开发时基于office2003开发的&#x…

220314

1.快慢指针 主要用于链表遍历节点的功能 class Solution {public ListNode removeNthFromEnd(ListNode head, int n) {//要想能够返回头节点&#xff0c;需要给head节点添加一个头节点&#xff0c;便于返回结果ListNode dummyNode new ListNode(0);dummyNode.next head;//定…

jenkins

1 Jenkins简介 Jenkins 开源 Java开发的 提到是Java开发的&#xff0c;一定联想云心Jenkins jdk环境 持续集成工具&#xff0c;用于监控持续重复的工作 假设没有Jenkins的话会是怎样&#xff1f; 《Git学习之旅》《Maven学习之旅》 平时去开发一个项目 每当修改了功能或者完善了…

20101206

time: 2010-12-6 9:56:57<-------主题&#xff1a;记录并发送的回调ph_audio_rec_cbk------->ph_audio_rec_cbk&#xff1a;如需要记录到文件则record_mic_resample_stream&#xff0c;apply half-duples SPK driven attenuator&#xff0c;if (mode SPK has priority) …

101003 ~ 101009

20:54 2010-10-3 配置无线环境。 失败,网通限端口。 8:45 2010-10-4 开题报告。 无线环境已配置。 8:45 2010-10-5 继续开题报告。 8:30 2010-10-6 仍然是开题报告。 2010-10-7 搭车返程。 9:03 2010-10-8 开题报告。 9:09 2010-10-9 ~ 9:42 2010-10-9 笔…