head 1.1;
access;
symbols;
locks; strict;
comment @ * @;
1.1
date 2014.03.12.14.09.08; author root; state Exp;
branches;
next ;
desc
@this is the program in which i have created a file and then used write command using function.
@
1.1
log
@Initial revision
@
text
@#include
#include
#include
int writefile(int);
int openfile();
int main()
{
int fd,a,ret;
char *buff;
buff=(char*)malloc(10);
fd=openfile();
printf(“fd is %d\n”,fd);
a=writefile(fd);
printf(“no of bytes in file is %d”,a);
lseek(fd,0,SEEK_SET);
ret=read(fd,buff,5);
printf(“\n no of bytes is %d and string is %s”,ret,buff);
return 0;
}
int openfile()
{
int fd;
fd=open(“file”,O_CREAT|O_RDWR,0666);
if(fd<0)
{
perror("file open");
exit(-1);
}
return fd;
}
int writefile(int fd)
{
int ret;
const char *a="priya";
ret=write(fd,a,5);
return ret;
}