I have written a piece of code that reads from one file and puts it in the other file
#include <stdio.h>
#include <fcntl.h>
int main()
{ char i[BUFSIZ];
int f=open("test.txt",O_RDONLY,0);
int y=open("test2.text",O_WRONLY,0);
read(f,i,13);
write(y,i,13);
read(f,i,1);
write(y,i,1);
read(f,i,13);
write(y,i,13);
printf("%d %d %d",i[11],i[12],i[13]);
read(f,i,1);
write(y,i,1);}
The test file from which it will read is text.txt
My name is charles manson
Thanks
and copy it in the file test2.text. The problem is that whenever I am reading from the file it is reading new line character two times as the output shows
PS C:\Users\HOME\Desktop\New folder> gcc run.c
PS C:\Users\HOME\Desktop\New folder> .\a.exe
10 10 0
and the contents in test2.text are written as
My name is charles manson
T
Please help :-(