-4
pwd
    A1.txt

I want to do this.

std::ifstream in("A*.txt");

Is there any method of doing this?

v78
  • 2,803
  • 21
  • 44
  • 1
    You can use [`glob.h`](http://pubs.opengroup.org/onlinepubs/009695399/basedefs/glob.h.html) to [gather files using wildcards](https://stackoverflow.com/questions/8401777/simple-glob-in-c-on-unix-system) – Cory Kramer Apr 27 '17 at 13:11
  • please add more context to the problem and do clean up the "REad" in your title – Passer By Apr 27 '17 at 13:14
  • @PasserBy, There is nothing to add. Currently I am not able to read the files. It is the only matching file btw – v78 Apr 27 '17 at 13:32

1 Answers1

1

There is no filename matching functionality in the C++ standard library.

POSIX provides the glob function in the glob.h header. Non-POSIX systems may have their own API for filename matching which may or might not differ from POSIX in behaviour.

If you cannot rely on non (C++) standard functionality, then you could of course implement filename matching yourself. However, prior to the upcoming C++17 standard, there is no way to get the file listing of a directory using the C++ standard library, so until then you have to rely on a platform specific API (or a wrapper library).

eerorika
  • 232,697
  • 12
  • 197
  • 326