You are not logged in.

  • Login

1

Saturday, February 17th 2007, 9:01pm

Nach bestimmter Endung suche

Habe folgenden Code im Inet gefunden:

C Quellcode

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
#include <windows.h> 
#include <conio.h> 
#include <stdio.h> 
 
char *fbprint(char *format, ...) 
{ 
  static char buf[1000]; 
 
  vsnprintf(buf, sizeof(buf), format, (&format)+1); 
  return (char *)buf; 
} 
 
void dirsearch(char *path, char *filter) 
{ 
  HANDLE hFindFile; 
  WIN32_FIND_DATA wfd; 
 
  hFindFile = FindFirstFile(fbprint("%s\\%s", path, filter), &wfd); 
  if (hFindFile != INVALID_HANDLE_VALUE) 
    { do 
          if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) 
              printf("%s\\%s\n", path, wfd.cFileName); 
      while(FindNextFile(hFindFile, &wfd) != 0); 
      FindClose(hFindFile); 
    } 
} 
 
int main() 
{ 
  dirsearch("c:", "*.txt*"); /* Pfad und Maske festlegen */ 
  getch(); 
  return 0; 
}

Abe wie muss ich jetzt den Code schreiben das path und wfd.cFileName zusammen gehängt sind?

2

Monday, February 19th 2007, 9:24am

C Quellcode

1
2
3
4
char *pFullPath = new char [strlen (path) + 1 + strlen (wfd.cFileName) + 1];
sprintf (pFullPath, "%s\\%s", path, wfd.cFileName);
....
delete pFullPath;


Alles klar?

Similar threads

Social bookmarks