Re: write
- From: "Bill Cunningham" <nospam@xxxxxxxxx>
- Date: Sun, 27 Apr 2008 22:04:48 GMT
To correct your program...
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main (void) {
int file;
char buf[]="hello world\n";
size_t c;
/*
c = 20000;
*/
if ((file = open("my_file",O_WRONLY | O_CREAT | O_TRUNC,0644)) != -1)
{
c = sizeof(buf);
write(file,buf,c);
close(file);
}
}
Hope this helps
Yes. Great! Exactly what I was looking for. I guess I need to include
more headers. But where is it descided in the program that the file opened
written to and eventually closed is going to be a binary or text file?
Bill
.
- Follow-Ups: