Mapper
cpfile.c
Go to the documentation of this file.
1 #define _POSIX_SOURCE
2 #include "prototypes_new.h"
3 
4 void cpfile(char *fromfile,char *tofile)
5 
6 {
7 
8 FILE *fr,*fw;
9 char kbuf[10000];
10 int ier;
11 
12 fr=fopen(fromfile,"r");
13 
14 if(fr==NULL) {
15 
16  printf("could not open %s for read\n",fromfile);
17  exit(1);
18 
19  }
20 
21 fw=fopen(tofile,"w");
22 
23 if(fw==NULL) {
24 
25  printf("could not open %s for write\n",tofile);
26  exit(1);
27 
28  }
29 
30 for(;;) {
31 
32  ier=fread(kbuf,sizeof(char),10000,fr);
33 
34  if(ier==0)
35  break;
36 
37  fwrite(kbuf,sizeof(char),ier,fw);
38 
39 }
40 
41 fclose(fr);
42 fclose(fw);
43 
44 chmod(tofile,S_IRUSR | S_IWUSR |
45  S_IRGRP | S_IWGRP |
46  S_IROTH | S_IWOTH);
47 
48 
49 
50 }
51 
52 
void cpfile(char *fromfile, char *tofile)
Definition: cpfile.c:4
fclose(fp)
printf("fbuf is %s\n", fbuf)