69,381
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#define MAX 89
struct M4V{
int TotalNum; //片段总数
int CurrentNum; //本次应答数
int ID; //应答ID
char StartTime[14]; //开始时间
int TimeList; //时长播放时间
};
int selectfile(const struct dirent *drt)
{
if(strstr(drt->d_name, ".c") != NULL)
return 1;
else
return 0;
}
main()
{
struct dirent **namelist;
struct M4V **list;
int i, total;
char buff[MAX][13]={0};
total = scandir("./scandir",&namelist, selectfile, alphasort);
printf("total = %d\n", total);
if (total < 0)
{
printf("scandir error: %d\r\n", total);
return 0;
}
for (i = 0; i < total; i++)
{
strncpy(buff[i],namelist[i]->d_name,12);
printf("%d->%s\n",i, buff[i]);
strcpy(list[i]->StartTime, buff[i]);
}
for (i = 0; i < total; i++)
strcpy(list[i]->StartTime, buff[i]);
// buff[13] = '\0';
for(i = 0; i < total; i++)
printf("%s\n", list[i]->StartTime);
}