]> git.armaanb.net Git - stagit.git/blob - src/cp.c
Fix cp function location
[stagit.git] / src / cp.c
1 #include <stdio.h>
2 #include <stddef.h>
3
4 int
5 cp(const char fileSource[], const char fileDestination[])
6 {
7         int c;
8         FILE *stream_R, *stream_W; 
9
10         stream_R = fopen(fileSource, "r");
11         if (stream_R == NULL)
12                 return -1;
13         stream_W = fopen(fileDestination, "w");   //create and write to file
14         if (stream_W == NULL)
15         {
16                 fclose(stream_R);
17                 return -2;
18         }    
19         while ((c = fgetc(stream_R)) != EOF)
20                 fputc(c, stream_W);
21         fclose(stream_R);
22         fclose(stream_W);
23
24         return 0;
25 }