C++高手帮忙写个程序

来源:百度知道 编辑:UC知道 时间:2024/05/22 07:57:10
在C盘下有个叫WHO的文件夹,里面有上百个.txt的文件,现在要求输入文件名,如果文件存在,让它输出路径…最好给点注释…谢谢

#include <fstream>
#include <string.h>
using namespace std;
int main()
{
char path[100] = "C:\\WHO\\";
char buf[20];
cout<<"input file name"<<endl;
cin>>buf;
strcat(path,buf);
ifstream fin;
fin.open(path);
if(fin.good())
cout<<"path is:\t"<<path<<endl;
else
cout<<"file:"<<buf<<" not exsit!"<<endl;
fin.close();
return 0;
}

要写什么程序呀,要实现什么功能?