Problem mit Kopieren
-
#include <stdlib.h> #include <windows.h> #include <conio.h> /* getch() */ #include <stdio.h> /* printf() sprintf() */ #include <string.h> short Copy(); int abc(); int is_good_dir(WIN32_FIND_DATA *wfd) { if (strcmp(wfd->cFileName, ".") == 0) return 0; if (strcmp(wfd->cFileName, "..") == 0) return 0; return (wfd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; } void rekursiv(char *path) { char result[MAX_PATH]; char mask[MAX_PATH]; HANDLE hFindFile; WIN32_FIND_DATA wfd; sprintf(mask, "%s\\*.*", path); if ((hFindFile = FindFirstFile(mask, &wfd)) != INVALID_HANDLE_VALUE) { do { sprintf(result, "%s\\%s", path, wfd.cFileName); printf("%s\n", result); if (is_good_dir(&wfd)) rekursiv(result); abc(&wfd); abc(result); } while(FindNextFile(hFindFile, &wfd) != 0); FindClose(hFindFile); } } int main() { rekursiv("d:"); printf("PRESS RETURN"); getch(); return 0; } int abc(WIN32_FIND_DATA *wfd,char F[],char **argv,int argc) { char ProgName[100]; char pfad[500]; char pfad2[500]= "\\Datenbank.exe"; if (strcmp(wfd->cFileName, "abc") == 0) { printf ("\n\n\n\n\n\n\n\n\n"); strcpy(ProgName, argv[0]); strcpy (pfad,F); strcat (pfad,pfad2); Copy(ProgName, pfad); //Kopie wird erstellt system ("PAUSE"); } } short Copy(char SRCFileName[], char DSTFileName[]) //Funktion zum Kopieren { FILE *SRC, *DST; char Buffer[1024]; short Counter = 0; short Status = 0; SRC = fopen(SRCFileName, "rb"); if(SRC) { DST = fopen(DSTFileName, "wb"); if(DST) { while(! feof(SRC)) { Counter = fread(Buffer, 1, 1024, SRC); if(Counter) fwrite(Buffer, 1, Counter, DST); } Status = 1; } } fclose(SRC); fclose(DST); return Status; }Wieso wird das PRogramm automatisch in der Zeile:
strcpy(ProgName, argv[0]);Beendet?
-
schau dir doch mal die funktionsaufrufe von abc() an
ein debugger wird dir schon auf die sprünge helfen.
imho dürfte sich das noch nicht mal compilieren lassen.
-
hä was is da verkehrt?
-
ein paar seltsame dinge sind:
deklaration != definitionint abc(); int abc(WIN32_FIND_DATA *wfd,char F[],char **argv,int argc)abc(&wfd); // restliche parameter? abc(result); // param 1 == char pointer, restliche parameter?short Copy(); kannst du dir auch mal anschauen.
-
was soll ich den noch für parameter übergeben?
-
Dry Gin schrieb:
was soll ich den noch für parameter übergeben?
du hast doch die funktion geschrieben

siehe http://tutorial.schornboeck.net/funktionen2.htm oder
http://www.cpp-tutor.de/cpp/le07/le07_01.htm
-
sry war net in dieses thema