Quick Question: Unix System Calls ???

This is a discussion on Quick Question: Unix System Calls ??? within the C Programming forums, part of the General Programming Boards category; We have to use Unix system calls to read something from file, and write it to screen Now... http://www.softpanorama.org/Internal...em_calls.shtml iint ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    167

    Quick Question: Unix System Calls ???

    We have to use Unix system calls to read something from file, and write it to screen

    Now...
    http://www.softpanorama.org/Internal...em_calls.shtml

    iint read(int fd, char *buf, int nbytes);
    int write(int fd, char *buf, int nbytes);

    I understand opening a file with "int fd" and giving that to read.

    But... How do we make write() work if we want to print to screen? What do we give as the first argument to write()? (Because there is no file I want to write to)

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    file descriptors for "console/terminal" is standardized at:
    stdin = 0
    stdout = 1
    stderr = 2

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by matsp View Post
    file descriptors for "console/terminal" is standardized at:
    stdin = 0
    stdout = 1
    stderr = 2

    --
    Mats
    THANKS!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick question about types...
    By Elysia in forum C++ Programming
    Replies: 32
    Last Post: 12-07-2008, 05:39 AM
  2. Replies: 3
    Last Post: 06-13-2005, 08:28 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 05:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 12:04 PM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 06:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21