data from terminal to a local file.
what I am trying to accomplish is to catch output from keyboard and direct it to a file:
I am able to compile this perfectly fine. When I execute the binary it asks for input from terminal. file.out is created on local disk but... it is always empty.
int out, len;
out = open("file.out", O_CREAT, S_IWUSR|S_IRUSR);
len = read(0, &buffer, 128);
write(out, &buffer, len);
} while((len = read(0, &buffer, 128)) >= 128 );