We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8e2f2ee commit 87520b5Copy full SHA for 87520b5
prog.17.1.c
@@ -0,0 +1,35 @@
1
+// Program to copy on file to another -- version 2
2
+
3
+#include <stdio.h>
4
5
+int main (int argc, char *argv[])
6
+{
7
+ FILE *in, *out;
8
+ int c;
9
10
+ if ( argc != 3 ) {
11
+ fprintf (stderr, "Need two file names\n");
12
+ return 1;
13
+ }
14
15
+ if ( (in = fopen (argv[1], "r")) == NULL ) {
16
+ fprintf (stderr, "Can't read %s.\n", argv[1]);
17
+ return 2;
18
19
20
+ if ( (out = fopen (argv[2], "w")) == NULL ) {
21
+ fprintf (stderr, "Can't write %s.\n", argv[2]);
22
+ return 3;
23
24
25
+ while ( (c = getc (in)) != EOF ) {
26
+ putc (c, out);
27
28
29
+ printf ("File has been copied.\n");
30
31
+ fclose (in);
32
+ fclose (out);
33
34
+ return 0;
35
+}
0 commit comments