*. * in argv [1] in C

Reference Information. Some Windows command-line programs allow you to use *.* In your first argument:

 myprogram *.* 

and it will automatically cycle through all the files in the directory.

Some others are not, therefore a batch cycle is required:

 for %%c in ("*.*") do myprogram "%%c" 

Question: Is there a standard way (defined in C or provided by the operating system?) To allow *.* Or *.txt in the argument so that it automatically processes the corresponding files

 int main(int argc, char *argv[]) { FILE *kf; "for fname in argv[1]" // pseudo code here meaning: // let loop on all files described by the first argument { kf = fopen(fname, "rb"); ... } } 

I wanted to check if there is a solution for this before flipping my own (reinvent the wildcard expansion wheel using FindFirstFile, etc.).

+5
source share
1 answer

No, there is no standard way to do this. Something needs to be processed. "Inside the main function. However, there may be some libraries that go beyond the main body of the C library that do what you need. In addition, you can write a batch file that will cycle through a set of files and invoke a C-written application, as described in the Windows Line File, passing through directories for processing files?

0
source

Source: https://habr.com/ru/post/1272720/


All Articles