Thread: Quick Question: Unix System Calls ???

  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, 07:28 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM