如何知道它的名字打开一个txt文件.. [英] how to open a txt file just by knowing its name..

查看:100
本文介绍了如何知道它的名字打开一个txt文件..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在c ++ fopen()函数中,我们需要给出文件的完整路径及其名称。

但是如果我们只知道像xyz这样的名称,如何打开文件。 TXT"并且不知道文件的位置。

In the c++ fopen() function we need to give the full path of the file along with its name.
But how to open a file if we just know the name like "xyz.txt" and dont know the location of file.

推荐答案

我认为我们需要一个指针。


在Linux环境中,我们有外卡给这份工作。


在CLI中,当我们需要在某些目录下搜索文件时,我们可以输入选项卡,让os在此目录下显示该文件。


我不知道如何在C ++中这样做。
I think we need a pointer.

In Linux environment, we have wild card to this job.

In CLI, when we need to search a file under certain directories, we can type " tab ", to let the os to display the file under this directories.

I don''t know how to do that in C++.


如果你没有指定完整路径,那么假定文件是在PWD(当前工作目录)。
If you fail to specify the full path, the file is assumed to be in the PWD (present working directory).



如果未指定完整路径,则假定该文件位于PWD(目前的工作目录)。
If you fail to specify the full path, the file is assumed to be in the PWD (present working directory).



但是如果文件不在PWD中那么......会出错

but if the file is not in PWD then..it will give error


这篇关于如何知道它的名字打开一个txt文件..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆