Re: [dev] I wrote a pager - errno
On Fri, Sep 16, 2016, at 12:26 PM, u_AT_netbeisser.de wrote:
> > #include <errno.h>
> > #include <stdio.h>
> >
> > int main()
> > {
> > const int page_size = 22;
> > int count = 0;
> > int ch;
> > FILE *tty;
> >
> > if ((tty = fopen("/dev/tty", "a+")) == NULL)
> > return(errno);
> >
> > ch = getchar();
> > while (ch != EOF) {
> > putchar(ch);
> > if (ch == '\n') {
> > ++count;
> > if (count >= page_size) {
> > fgetc(tty);
> > count = 0;
> > }
> > }
> > ch = getchar();
> > }
> > fclose(tty);
> > }
>
> hm, do you really need errno ?
Well, I don't know. Like I wrote, I am not an expert C programmer. I
could just return a value of 1, but the user might be interested to know
what the error was.
Received on Fri Sep 16 2016 - 22:24:32 CEST
This archive was generated by hypermail 2.3.0
: Fri Sep 16 2016 - 22:36:11 CEST