Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

C++ Reading filenames


ghost's Avatar
0 0

I'm tryin to write a program for my neighbor to read the decapitalize all the names of the files he recieves from his clients (he does web design, and the images for some reason don't work when capitalized). I have everything figured out, as I wrote a similar program yesterday to decapitalize text files. But the problem I'm having is I don't know of anyway that I can read a single filename into a string so that it could then be decapped. I've been researching and I think the dirrent.h header file might have something, but I can't find what I'm looking for. Anyone got any ideas?

Basically I wan't the program to read the name of each file into a string. Then when it's done with the decapitalizing and renaming, move to the next file until all the files have been decapped.

Thanks for any help, Howie


ghost's Avatar
0 0

i know this is not really a solution but you can do this in c# in like 2 mins if and the syntax is very similar. if you choose to do it in c# hit me up and ill help you out. otherwise if your not in too much of a rush i can code it for you in c# and send you the program :)


ghost's Avatar
0 0

thanks for the offer, but I'd like to learn how to do this in C++. And this project is more of just for the fun of programming.

Howie


ghost's Avatar
0 0

to read files and create files learn about simple fstream, i know you can read names in c# but im not sure about ++


ghost's Avatar
0 0

yea the fstream in C++ only allows you to read the contents of a specified file, or write to a specified file. I just need to read the names of the files.


ghost's Avatar
0 0

vectors i dont have it with me but a freind of mine showed me how to read all the files in a dir into a array or vector i would deffently google it if i find it ill post it

i used the arrays like this

array_name[#];


ghost's Avatar
0 0

I googled for Vectors found a really nice tutorial on them, but that is just another kind of variable. If you find that script though, I'd love to take a look at it. Either post it or pm it to me. Thanks Howie