Re: write
- From: "Bill Cunningham" <nospam@xxxxxxxxx>
- Date: Sun, 27 Apr 2008 22:36:27 GMT
"Lew Pitcher" <lpitcher@xxxxxxxxxxxx> wrote in message
news:707af$4814f545$4c0a8485$12038@xxxxxxxxxxxxxxxxxxxx
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
At your file=open(). Doesn't open return a ssize_t ? You have file
declared as a int.
Bill
.