How do I get the number of bytes from stdin and input file using low level system calls? like read(2) & write(2)
I used lseek to get the number of bytes from input file but lseek will not work standard input.
I want to try to read the file or the standard input bytes by bytes and store them into an array and print out the total bytes that are in the file or the standard input. I tried using a for loop to do it. like for standard input...
while((x = read(0, bf, bsize)) > 0) //reading the standard input
{
for(int i = 0; i < n; i++)
{
//try to implement getting the total amount of bytes that are in STDIN here
}
}
This is what I tried to do but I think I am doing it wrong by using the for loop.
I'm really lost on how to implement getting the number of bytes that are in the standard input and in the input file. Can someone help me please?