Understanding the write function

Solved
Hello, I just used the write function without really understanding it, so I would like some explanations.
Here's my function: write(1, &c, 1)
I would like to know what each thing in the parentheses corresponds to.
Thank you.

Configuration: iPhone / Firefox 32.0

3 answers

  1. Contributor
    Hello,

    There's no need to duplicate requests, we won't respond any faster...

    You need to refer to the man: http://manpagesfr.free.fr/man/man2/write.2.html

    For your information, write() is not standard. We usually use fwrite().

    Otherwise, for write(), the type is: ssize_t write(int fd, const void *buf, size_t count)
    So for the first argument, you need the descriptor. As for the second, you need the address of a pointer. So rather "0123456789" in quotes. And finally the size, that's okay.

    Regards,
    --

    Google is your friend
    -1
    1. Hello
      it should be understood what @fiddy means that fwrite is of type ANSI C and better optimized than write which is of type POSIX that is not well optimized for reading files compared to ANSI
      see you soon
      0
    2. Contributor
      I mainly wanted to say that fwrite() will work on any system. The other one will only work on POSIX.
      Additionally, these are not functions of the same level.
      Moreover, write() is blocking, etc. In short, the advantage of using wrappers is also to program while abstracting away from the system layer...
      0
    3. Exactly, but sometimes we need to take this system aspect into account, and I ask myself the following question: does a completely pure ANSI operating system exist?
      0
    4. Contributor
      It is not the system that is ANSI.
      In other words, if you program in standard C, as soon as you have a compiler, there will be the libc library implemented to ensure the program runs.
      For Posix, it is a different logic. That’s why it’s not the same level.
      0
    5. Yes, I understand that, but could we not have all the layers of a portable system and, by definition, have an indirectly portable system or even a portable system outright? Even if applying it is different from the idea.
      0