Reading files in C++, using *.
Hello:
I have a question and I hope you'd be so kind to help me: I have this program, let's call it myProgram.exe, I wrote it under c++. Now this program reads a file and processes it, the file that's gonna be read will be specified as a parameter in command line: myProgram thisThing.h so it will read the file thisThing.h . I want it to be able to accept several files: myProgram a.h b.h c.h And read and processes them all. I have managed to do that, but I'd like to use the *.h and make it read all .h files there are in the directory, is that possible? myProgram *.h how can I get a list of the files that are in the directory and then choose those with .h ??? thanks a lot in advance for your time and your help Poeta ---- Almost to newbie to funcion :cry: ------ |
The shell handles filename expansion for you. Here's a little example program I wrote to show you:
Code:
#include <stdio.h> Number of files: 2 bar.c foo.c And as it turns out, those are the only files in that directory that end with .c ;) |
thanks a lot! I thought I had to manage that
Thanks thanks! |
hello again:
I couldnt do what you said... does it matter if I'm using windows? I did this: vector<string> comandos; for(int i = 1; i < argc ; i++) comandos.push_back(argv[i]); and when I call: me.exe *.h it says: *. file cant be found I dunno what happens? |
sorry.... doublr posted so I erase this one.
please help :cry: |
All times are GMT -5. The time now is 05:46 AM. |