head 1.1;
access;
symbols;
locks
root:1.1; strict;
comment @ * @;
1.1
date 2014.03.14.06.52.50; author root; state Exp;
branches;
next ;
desc
@this is the initial version,file created and open using function().
@
1.1
log
@Initial revision
@
text
@#include”header.h”
int main(int argc, int *argv[])
{
int fd,ret;
char ch;
if(argc !=2)
{
printf(“insufficient arguments”);
goto out;
}
fd=openfile(argv[1]);
do
{
ret=read(fd,&ch,1);
if(ret<0)
{
perror("read");
close(fd);
goto out;
}
if(ch!=10)
{
masterarray[ndc]=ch;
ndc++;
}
}while(ch!=10);
for(i=0;i<ndc;i++)
printf("read %d char ch=%c \n",ret,masterarray[i]);
return 0;
out:
return -1;
}
int openfile(char *ipfile)
{
int fd;
fd = open(ipfile,O_RDONLY);
if(fd<0)
{
perror("open");
goto out;
}
printf("file discriptor : %d",fd);
return fd;
out:
return 0;
}
@