EmbLogic's Blog

file handling

#include<stdio.h>

#include<stdlib.h>

#include<fcntl.h>

int main()

{

int count,fd;

char buf[50];

fd=open(“filem.c”,O_RDONLY,S_IRWXU);

count=read(fd,buf,50);

if(fd<0)

{

perror(“open”);

exit(-1);

}

printf(“the value of count=%d and value of buf=%s”,count,buf);

close(fd);

}

 

note :-       where file : filem.c contain data “she sells sea shell at sea shore”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>