Fred K Ollinger on Thu, 20 Jun 2002 03:31:16 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] this code crashes [OT]


Here's the whole (broken) function:


int voxInstallCommon::cp(char *src, char *dst)
{
#define MAX_BUF 1024
cout << "src:" << src << ", " << "dst:" << dst<< "\n";
char buffer[MAX_BUF+1];

size_t bytes_read;
FILE *source, *dest;

source = fopen(src, "r");
dest = fopen(dst, "w");
memset(buffer, 0, MAX_BUF);

bytes_read = fread(buffer, 1, MAX_BUF, source);

while(bytes_read)
{
    fwrite(buffer, 1, bytes_read, dest);
    bytes_read = fread(buffer, 1, MAX_BUF, source);
}

fclose(dest);
return 0;

}


______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug