EmbLogic's Blog

started working with mdc(master array using function)

head 1.2;
access;
symbols;
locks
root:1.2; strict;
comment @ * @;

1.2
date 2014.03.15.16.06.03; author root; state Exp;
branches;
next 1.1;

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.2
log
@implemented masterarray using function
@
text
@#include”header.h”

int main(int argc, char *argv[])
{
int fd,ret;

if(argc !=2)
{
printf(“insufficient arguments !!”);
goto out;
}
fd=openfile(argv[1]);
masterarray(fd);
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;
}
int masterarray(int fd)
{
int ret,i,ndc=0;
char ch;
char masterarray[128];
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]);
out:
return -1;
return 0;
}
@

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>