write



I tried to write with this call and I don't know what happened. I really
don't know much about it.
Here's my code -

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

int main (void) {
int file;
char buf[]="hello world\n";
size_t c;
c=20000;
write(file,buf,c);
}

Now there must be a call somewhere that C compilers call when using
fopen. This call didn't open anything for me. Also this call must only write
binary and not text. I ran this code it compiled great and did nothing
apparent. So I used dd to write zeros to a file called "file". An empty
file. Then I ran the code and used linux's file keyword to see what type of
file it was and it was data. I used a text editor to open the file and it
didn't work.

What are the uses and limitations of write() and I assume read() is the
same. C's fopen in text mode must call another syscall.

Bill


.



Relevant Pages

  • Re: "extern" specifier ?
    ... int count; ... void f1 ... most early C compilers ... implemented global definitions as above more or less as if they ...
    (microsoft.public.vc.language)
  • Scope/use of prototypes Qs
    ... int DATASIZE = MAXSIZE; ... void getdata; ... with a few different compilers ... ...
    (comp.lang.c)
  • Re: [v11][PATCH 8/9] Define clone_with_pids() syscall
    ... Here is a stab at the s390 syscall. ... args to the child function and continuing to run - but I ... int do_child ... void *fnarg) ...
    (Linux-Kernel)
  • Re: a little mistake
    ... Also the use of "inline" for that function is redundant. ... compilers will do it anyways and it isn't portable across all compilers ... int main ... Calling function would be part of the users code. ...
    (comp.lang.c)
  • protected by instance, not by type?
    ... compilers and are unsure whether or not the compiler is right. ... I allway thought the C++ type system only relies on static types. ... int privA; ... void protMethB ...
    (comp.lang.cpp)