博客专栏

EEPW首页 > 博客 > [c practice]打印一个文件夹下有规律的几个文件名字

[c practice]打印一个文件夹下有规律的几个文件名字

发布人:电子禅石 时间:2020-02-29 来源:工程师 发布文章
#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

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



关键词:

相关推荐

技术专区

关闭