you can read the text file using fread and you can write the content using fwrite.

the read and write system calls are allowed only for files. it will never read a special files. like directory , socket, FIFO,

if you want to read a directory you can use opendir.

you can specify the buffer size in read and write. if you cant to read single character or single line at a file.