With this code I found here on Stack:
...
char buffer[256]
while((count=read(0, buffer, 256)) > 1)
{
if(buffer[count] = '\n') break;
}
buffer[n-1] ='\0';
I can read from the standard input, but I have 2 questions:
- Why is
'='
used in the if() instead of'=='
? - If I press
CTRL-C
after writing something, how can I keep what I wrote?
Thanks