#include<string.h>
#include<fcntl.h>
int main()
{
int i,j,fd,len,maslen=1;
char arr[100]={0};
char masterarr[25]={0};
fd=open(“add.c”,O_RDONLY);
i=0;
while(read(fd,&arr[i],1))
i++;
len=strlen(arr);
for(i=0;i<len;i++)
{
for(j=0;j<maslen;j++)
{
if(j+1==maslen)
{
masterarr[j]=arr[i];
maslen++;
break;
}
else
{
if(masterarr[j]==arr[i])
break;
}
}
}
printf(“masterarr=%s\n”,masterarr);
return 0;
}
instead of using while,can we use the return value of read untill it returns 0
when it returns 0,it means all the chars in string has been read.
??