Re: write
- From: "Bill Cunningham" <nospam@xxxxxxxxx>
- Date: Sun, 27 Apr 2008 23:49:04 GMT
Here's my new code that seems to work great.
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
int main() {
int file;
if((file=creat("fil",S_IRUSR))==-1) {
fprintf(stderr,"error\n");
return -1;
}
char buf[]="string\n";
ssize_t t;
if((t=write(file,buf,200))==-1) {
fprintf(stderr,"write error\n");
return -1;
}
int a;
if((a=close(file))==-1) {
fprintf(stderr,"close error\n");
return -1;
}
return 0;
}
And when I opened this file with a text editor the word "string" was
nicely printed. The only thing is file reports it as a data file and not a
text file.
Bill
.
- References:
- Prev by Date: Re: write
- Next by Date: Re: write
- Previous by thread: Re: write
- Next by thread: Re: write
- Index(es):
Relevant Pages
|