Skip to content
Snippets Groups Projects
Commit 14e886bc authored by iliya.saroukha's avatar iliya.saroukha
Browse files

finished copyf

parent 9f3bfa6f
Branches
No related tags found
No related merge requests found
......@@ -2,6 +2,11 @@
#include <stdlib.h>
#include "lib_fs.h"
// int copy(char *src, char *dst, unsigned int buf_size)
// {
// }
int copyf(char *src, char *dst, unsigned int buf_size)
{
FILE *fp_src = fopen(src, "r");
......@@ -23,12 +28,12 @@ int copyf(char *src, char *dst, unsigned int buf_size)
while (!feof(fp_src))
{
fread(str, sizeof(char), buf_size, fp_src);
byte_count += buf_size;
size_t real_size = fread(str, sizeof(char), buf_size, fp_src);
fprintf(stdout, "Real number of bytes copied : %zu\n", real_size);
fwrite(str, sizeof(char), real_size, fp_dst);
byte_count += real_size;
}
fwrite(str, sizeof(char), buf_size, fp_dst);
fclose(fp_src);
fclose(fp_dst);
......
......@@ -15,7 +15,7 @@ int main(int argc, char **argv)
char *src = "./src.txt";
char *dst = "./dst.txt";
fprintf(stdout, "Number of bytes copied: %d\n", copyf(src, dst, atoi(argv[1])));
fprintf(stdout, "\nNumber of bytes copied: %d\n", copyf(src, dst, atoi(argv[1])));
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment