函数findfirst()怎么用

笑面佛_正版 2002-04-28 02:54:49
在 dir.h 中 定义的用法是这样

int findfirst(const char *path, struct ffblk *ffblk,int attrib);

我用这样的代码他老说我的 t 变量指针有错,而且也不知道这个函数的作用是何,用法又
是怎么样的,哪位仁帮帮我

int s;
struct ffblk *t;
s=findfirst("C:\WINDOWS",t,0);

...全文
377 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
唐古拉山 2002-04-28
  • 打赏
  • 举报
回复
给你一段程序参考,使用 BC31
----------------------------

#include <stdio.h>
#include <stdlib.h>
#include <dir.h>
#include <dos.h>
#include "conio.h"

#define ALL FA_RDONLY |FA_HIDDEN | FA_SYSTEM | FA_LABEL | FA_ARCH

void dirme(char * pfad);

void main()
{
clrscr();
dirme("c:\\*.*");
getch();
dirme("c:\\windows\\*.*");
getch();
}

void dirme(char * pfad)
{
struct ffblk block;
int ret;
int num=0;
for (ret=findfirst(pfad,&block,ALL);!ret; ret=findnext(&block))
{
printf("File%d : %s\n",num++,block.ff_name);
}
fangrk 2002-04-28
  • 打赏
  • 举报
回复
int s;
struct ffblk t;
s=findfirst("c:\\windows",&t,0);
wuhuar 2002-04-28
  • 打赏
  • 举报
回复
你要初始化一下你的指针t
fangrk 2002-04-28
  • 打赏
  • 举报
回复
s=findfirst("C:\\WINDOWS",t,0);
jbmw 2002-04-28
  • 打赏
  • 举报
回复
你定义了个未初始化的指针变量,所以出错了!!!
int s;
struct ffblk t;
s=findfirst("c:\windows",&t,0);

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧