count number of files with a given extension in a directory - C++?

前端 未结 3 506
慢半拍i
慢半拍i 2021-01-15 04:35

Is it possible in c++ to count the number of files with a given extension in a directory?

I\'m writing a program where it would be nice to do something like this (ps

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-15 04:44

    First of all what OS are you writing for?

    • If it is Windows then look for FindFirstFile and FindNextFile in MSDN.
    • If you are looking the code for POSIX systems, read man for opendir and readdir or readdir_r.
    • For cross platform I'd suggest using Boost.Filesystem library.

提交回复
热议问题