#include "stdio.h"
#include "stdlib.h"
#define BUFFER_SIZE 1024
long fcopy(char *dest, char *source)
{
FILE *d, *s;
char *buffer;
size_t incount;
long totcount = 0L;
s = fopen(source, "rb");
if(s == NULL)
return -1L;
d = fopen(dest, "wb");
if(d == NULL)
{
fclose(s);
return -1L;
}
buffer = malloc(BUFFER_SIZE);
if(buffer == NULL)
{
fclose(s);
fclose(d);
return -1L;
}
incount = fread(buffer, sizeof(char), BUFFER_SIZE, s);
while(!feof(s))
{
totcount += (long)incount;
fwrite(buffer, sizeof(char), incount, d);
incount = fread(buffer, sizeof(char), BUFFER_SIZE, s);
}
totcount += (long)incount;
fwrite(buffer, sizeof(char), incount, d);
free(buffer);
fclose(s);
fclose(d);
return totcount;
}
#include "stdlib.h"
#define BUFFER_SIZE 1024
long fcopy(char *dest, char *source)
{
FILE *d, *s;
char *buffer;
size_t incount;
long totcount = 0L;
s = fopen(source, "rb");
if(s == NULL)
return -1L;
d = fopen(dest, "wb");
if(d == NULL)
{
fclose(s);
return -1L;
}
buffer = malloc(BUFFER_SIZE);
if(buffer == NULL)
{
fclose(s);
fclose(d);
return -1L;
}
incount = fread(buffer, sizeof(char), BUFFER_SIZE, s);
while(!feof(s))
{
totcount += (long)incount;
fwrite(buffer, sizeof(char), incount, d);
incount = fread(buffer, sizeof(char), BUFFER_SIZE, s);
}
totcount += (long)incount;
fwrite(buffer, sizeof(char), incount, d);
free(buffer);
fclose(s);
fclose(d);
return totcount;
}
here shows some error i.e. can't convert to void* into char* in function fcopy(char*,char*)...
ReplyDeletei hv used turbo c 4.5
Friend Please Use Older version Of C Compiler..
ReplyDelete