Hello,
I am programming some kind of shell in special distribution of Linux. My trouble comes with programming the sort function. It should work the same like in the standard shell. When you terminate input, there's need to put End Of Transmission character, which is CTRL+D. But I am not able to do it right. I tried this:
while (!feof(stdin)) {
fgets(buf, MAXBUF, stdin);
AddToArray(buf, strlen(buf) + 1);
i++;
}
but if the ctrl+d didn't come right after new line (enter), i need to press it twice. So it doesn't work right. Please, would you have any advice?
Thank you very much!
Samuel