Finding File names

Ok, so here's the plan. I want to rename every file in a directory to the original name with the exception of the first 3 characters (ex. example.exe to mple.exe) My plan is relatively strait forward, the only problem I have is I cant figure out how to find all of the file names and put them in an array. I can list them all, but I can only manage to capture the last one in the directory in a variable. So my question is does anyone know how to capture the names in an array. Thus far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*#include <stdio.h>

int main ()
{
  int result;
  char oldname[] ="oldname.txt";
  char newname[] ="newname.txt";
  result= rename( oldname , newname );
  if ( result == 0 )
    puts ( "File successfully renamed" );
  else
    perror( "Error renaming file" );
  return 0;
}
*/

#include<stdio.h>
#include<cstdlib>
#include<iostream>
#include<string.h>
#include<fstream>
#include<dirent.h>

void listFile();
int write();

char* times[0];
char* mp3[50000];
int x = -1;

using namespace std;

int main(){
    listFile();
  //  write();
    //cout << mp3[0];
    return 0;
}

void listFile(){
        DIR *pDIR;
        struct dirent *entry;
        if( pDIR=opendir("./") ){
                while(entry = readdir(pDIR)){
                        if( strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0 )
                        cout << entry->d_name << "\n";

                        mp3[1] = entry->d_name;
                        ofstream write ("name chomp.txt");




write << entry->d_name;
write.close();

                }
                closedir(pDIR);
        }
}









int write()
{

    ofstream write ("name chomp.txt");




//write <<  *entry;
write.close();
}



the whole write thing is just a debug. once i can do it all of that is going away.
FindFirstFile and FindNextFile is functions are you are looking.
Enjoy with this link http://msdn.microsoft.com/en-us/library/aa364232(v=VS.85).aspx
Topic archived. No new replies allowed.