#include”header.h”
int my_open(char*);
char* m_array(int);
int main(int argc,char*argv[])
{
int fd;
char *ma;
fd=my_open(argv[1]);
ma=m_array(fd);
printf(“the master array is %s”,ma);
}
int my_open(char*name)
{
int fd;
fd=open(name,O_RDONLY);
if(fd<0)
{
perror(“open”);
exit(-1);
}
printf(“file opened successfully with fd=%d”,fd);
return fd;
}
char*m_array(int fd)
{
char *ma;
char ch;
int count;
int flag=1;
int i=0;
int k;
ma=malloc(1);
read(fd,&ch,1);
*ma=ch;
while(read(fd,&ch,1))
{
flag=1;
for(k=0;k<=i;k++)
if(ch==ma[k])
{
flag=0;
break;
}
if(flag==1)
{
ma=realloc(ma,i+2);
ma[i+1]=ch;
i++;
}
}
return ma;