-
Can someone translate this code i got from Jop to C++. I am having most trouble with the dinamyc arrays.
Code:
Public Sub GetAllFilesAPI(StartDir As String)
Dim d$, dr As Boolean, dts As Boolean, dirs() As String
Dim FindData As WIN32_FIND_DATA, c%, file&
If Right(StartDir, 1) <> "\" Then StartDir = StartDir & "\"
ReDim dirs(0)
file = FindFirstFile(StartDir & "*", FindData)
c = 1
Do While c <> 0
c = FindNextFile(file, FindData)
d = StripNulls(FindData.cFileName)
dts = d <> "." And d <> ".." And Len(d) > 0
If dts Then dr = (GetFileAttributes(StartDir & d) And FILE_ATTRIBUTE_DIRECTORY)
If dr = False And dts Then Form1.List1.AddItem StartDir & d 'add to list
If dr And dts Then 'dir found
ReDim Preserve dirs(UBound(dirs) + 1)
dirs(UBound(dirs)) = d
End If
Loop
Dim x&
FindClose file
For x = 1 To UBound(dirs)
GetAllFilesAPI StartDir & dirs(x)
Next x
End Sub
-
-
-
this is a good a time as any to ask........... how do you use a vector?
-
vector is a template class, so you can make a vector of anything:
Code:
vector<int> viArray;
for(int j = 0; j < 10; j++) {
viArray.push_back(j);
}
for(j = 0; i < viArray.size(); j++) {
cout << " " << viArray[j];
}
cout << endl;
-
I pretty much tought my self how to use vectors in the past.. day... but what is push_back and push_forward(or whatever it's called) ??
-
push_back appends an item to the vector.
-
Thanks parksie. I finally translated that VB code. This vector stuff really helped a lot. Thanks again.
-
:doh!:
so I've been resizing and adding to my vectors for no reason?
well, thanks parksie :D