Re: write
- From: Baho Utot <baho-utot@xxxxxxxxxxxx>
- Date: 27 Apr 2008 22:17:20 GMT
On Sun, 27 Apr 2008 22:04:48 +0000, Bill Cunningham wrote:
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
At the fopen
A text file is nothing more than an array of binary "ASCII characters"
--
Tayo'y Mga Pinoy
.