新闻  |   论坛  |   博客  |   在线研讨会
[c practice]打印一个文件夹下有规律的几个文件名字
电子禅石 | 2020-02-29 13:42:16    阅读:839   发布文章

#include <stdio.h>
#include <string.h>
/* 小练习:就是打印./22 文件夹下 xx_1  xx_2 xx_3 三个文件*/
int find_file(unsigned char *path,int number)
{
 unsigned char file_path[18]={0};
 int i=0;
 strncpy(file_path,path,strlen(path));
 strcat(file_path,"xx_");
 printf("1 \n");
 for(i = 0;i < number; i++)
 {
  file_path[strlen(path) + 3] = i + 0x30;
  file_path[strlen(path) + 3 + 1] = '\0';
  printf("the file name is %s \n",file_path); 
 }
}
int main (int argc , char **argv)
{
 unsigned char path[18] = "./22/";
 find_file(path,3);
 return 0;
}

88.PNG

*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
属于自己的技术积累分享,成为嵌入式系统研发高手。
推荐文章
最近访客