Πρόσβαση στην παράλληλη θύρα

Giorgos Keramidas keramida at ceid.upatras.gr
Fri Apr 28 01:58:26 EEST 2006


On 2006-04-28 01:49, Chameleon <cham_gss at hotmail.com> wrote:
> >   15  int
> >   16  main(void)
> >   17  {
> >   18          unsigned char buf[256];
> >   19          size_t k;
> >   20          int fd;
> >   21
> > + 22          fd = open(PARALLEL_PORT, O_RDWR, S_IREAD | S_IWRITE);
> > + 23          if (fd == -1) {
> > + 24                  fprintf(stderr,
> > + 25                      "error: open: %s: %s\n",
> > + 26                      PARALLEL_PORT, strerror(errno));
> > + 27                  fflush(stderr);
> > + 28                  return EX_OSFILE;
> > + 29          }
[...]
>
> blepw oti xrhsimopoieis tis
> open anti fopen
> write anti fwrite
> close anti fclose
> yparxei skopimothta na mhn xrhsimopoieis tis default biblio8hkes ths C?

Ναι υπάρχει λόγος.  Οι fopen(), fprintf(), fwrite(), κλπ. μπορεί να
κάνουν εσωτερικά buffer τα δεδομένα.  Στη συγκεκριμένη περίπτωση αυτό
μπορεί να αποδειχθεί κακή ιδέα (ειδικά αν το συνδυάσεις με timer που
έλεγες πριν).




More information about the Linux-greek-users mailing list