Compare commits
3 Commits
f4c0563a3a
...
9b4fd1e5c1
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b4fd1e5c1 | |||
| 17abac161e | |||
| d10617f2d4 |
32
c_programming/files/copy.c
Normal file
32
c_programming/files/copy.c
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
FILE *input = fopen("in.txt", "r");
|
||||||
|
if (input == NULL)
|
||||||
|
{
|
||||||
|
perror("Failed to open in.txt");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
FILE *output = fopen("out.txt", "w");
|
||||||
|
if (output == NULL)
|
||||||
|
{
|
||||||
|
perror("Failed to open out.txt");
|
||||||
|
fclose(input);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
char c;
|
||||||
|
while (fread(&c, sizeof(char), 1, input) != 0)
|
||||||
|
{
|
||||||
|
fwrite(&c, sizeof(char), 1, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO:
|
||||||
|
+ clone: clone git repository and start working on copy.c
|
||||||
|
+ first: go through part 3 of cs50 week 4 memory section.pdf
|
||||||
|
+ make: get copy.c compiling with make
|
||||||
|
+ complete: fix all problems and ensure the demo program works as intended
|
||||||
|
+ wait: if I need to go work on another file, it will go in a wait: task.
|
||||||
|
*/
|
||||||
1
c_programming/files/in.txt
Normal file
1
c_programming/files/in.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
hi!
|
||||||
Reference in New Issue
Block a user