再纯dos下查找目录

realtole 2004-03-15 01:19:03
各位高手,我遇到一个困难,我要在纯dos下查找安装windows系统的目录(事先不知道windows系统安装在c:\windows,还是c:\win或者其他的什么目录
请问我要怎样用tc做?
...全文
27 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
柯本 2004-03-15
  • 打赏
  • 举报
回复
程序如下:
#include <dir.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main()
{
/* get the current path environment */
char *ptr,*apath;
char path[255];
struct ffblk ffblk;
apath = getenv("PATH");
ptr=strtok(apath,";");
while(ptr)
{
// printf("%s\n",ptr);
strcpy(path,ptr);
strcat(path,"\\win.com");
if (findfirst(path,&ffblk,0)==0)
{
printf("widnows find in %s\n",ptr);
break;
}
ptr=strtok(NULL,";");
}
}



柯本 2004-03-15
  • 打赏
  • 举报
回复
简单地可在path的路径下找win.com
首先,把得到环境变量path,然后分解,再用findfirst在path的每个目录下查win.com
有win.com的即为windwos系统目录
langziji 2004-03-15
  • 打赏
  • 举报
回复
findfirst, findnext

69,371

社区成员

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

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