c++ - Find filename extension in directory -
All,
I'm new to C ++, so I did not search for the correct function Can, vocabulary, etc. I'm using the getopt to get the argument on the command line. Those logic are directories on the local drive. When the code is executed, I want to see it in that directory for a certain file extension. When it searches for this extension, I'll do something with the file, change the name of the file, and then copy the file to second place. I'm trying to find the filename extension. As far as I am showing all the files in the directory:
main.cpp:
int opt = 0; / * If the argument number is passed, then check all arguments / when ((opt = getopt (argc, argv, "b: m: o: hh") = EOF) {switch (opt) {case 'b' : DirCopyEvent (Optage); breakdown; dirCopyEvent.cpp: zero dirCopyEvent (char * fileToFind) {cout < The directory selected "& lt; FileToFind dirCopyEvent is called the main. I know That I need to parse the D_Names for the file name and then in some way the extension will be found, but any help where I am lost will be very appreciable!
- Edit * To add just one example:
I have a directory called Test. In that directory, I have 3 files: test1.txt anothertest.txt yetanothertest.bat < P> I only want to be able to show the result of test1.txt and anothertest.txt, but Minister is not yettestest.bat when I got Tisitis extension called up, so I want to pass it to another function to do something with it.
Thank you!
You get the last event of the dot in the string just like the following.
char * extension; Extension = strrchr (dir-> d_name, '.');
Comments
Post a Comment