Sign in to follow this  
derek7

rename

Recommended Posts

I wanna do a program: 1. search a folder to find all file name. 2. call rename() to rename all file name to other. 1.how to do step 1? any function for that? 2.how to d a 2 dimension array? char c[][] or char ** c? stl is not consided. (vector<string> should be good)

Share this post


Link to post
Share on other sites
Quote:
Original post by derek7
I wanna do a program:
1. search a folder to find all file name.
2. call rename() to rename all file name to other.

1.how to do step 1? any function for that? 2.how to d a 2 dimension array?
char c[][] or char ** c? stl is not consided. (vector<string> should be good)
There's no way to do it with plain C or C++, you'll need to use platform specific functions (Such as Win32's FindFirstFile() and FindNextFile()) or a library like boost.
Both of those methods of doinf 2D arrays will work. If you want to dynamically allocate them though, you'll have to do a loop like so:

int nRows = 42;
int nCols = 69;
char** c = (char**)malloc(sizeof(char*) * nRows);
for(int i=0; i<nRows; ++i)
c[i] = (char*)malloc(sizeof(char) * nCols);


(Not including error checking)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this