Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C write() help

Name: Anonymous 2007-02-11 10:59

I just don't get how it works.
write(1, buffer, bytestowrite) writes to stdout.
if i open a file with open() and then do a write(2, etc..) it writes to that file.
thing is how do i know the number every time ? i don't get that :S

Name: Anonymous 2007-02-11 11:34

You have to recompile the kernel to get file pointers

Name: Anonymous 2007-02-11 12:15

man open
Given a pathname for a file, open() returns a file descriptor, a small, non-negative integer for  use  in  subsequent  system  calls  (read(2), write(2), lseek(2), fcntl(2), etc.).  The file descriptor returned by a successful call will be the lowest-numbered file  descriptor  not  currently open for the process.

Obviously you have to use the return value of open() as the first arg to write(). And I've never even done any serious C, I just looked at the manpage. Like you should have done.

Name: Anonymous 2007-02-11 12:42

>>3 cool man thanks for the help
the write man page didn't had that much info

Name: Anonymous 2007-02-11 13:47

>>4
You are seriously fucking stupid, and >>3 just owned you.  Don't even bother trying to program if you don't even know how to look things up that you don't understand.

Name: Anonymous 2007-02-11 14:17

>>5
how >>3 owned me ? That's ridiculous.

Name: Anonymous 2007-02-11 14:48

If successful, open() returns a non-negative integer, termed a file
     descriptor.  It returns -1 on failure.  The file pointer used to mark the
     current position within the file is set to the beginning of the file.

Name: Anonymous 2007-02-11 14:49

One word, the forced indentation of code. Thread over.

Name: Anonymous 2007-02-11 15:53

En un mot, l'indentation forcée du code. Conversation terminée.

Name: Anonymous 2007-02-11 20:03

Одним словом, вынужден отступы в код. Thread старше.

Name: Anonymous 2007-02-11 20:03

كلمة واحدة ، فقد اضطر التثليم من المدونه. على الخيط.

Name: Anonymous 2007-02-11 20:09

Oneway ordway, ethay orcedfay indentationway ofway odecay.
Eadthray overway.

Name: Anonymous 2007-02-11 20:14

>>9
Un seul mot, indentation forcée du code. Fin de discussion.

Name: Anonymous 2007-02-11 20:32

Ett ord, påtvingad indentering av kod. Tråden är över.

Name: Anonymous 2007-02-11 20:42

gb2/lang/

Name: Anonymous 2007-02-12 3:46

Una palabra, indentación forzada del código. Fin del hilo.

Name: Anonymous 2009-01-14 13:13

SICP

Name: Anonymous 2010-12-24 13:40

Name: Anonymous 2011-02-04 15:30

Name: Anonymous 2011-02-18 14:22

<-- check 'em

Name: Sgt.Kabu励ᛆkiman谢 2012-05-28 22:30

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List