another question about strcpy
Hello everyone.
I found on a book this function(I suppose it works)
which reads some lines and returns the number of lines readed.
Code:
int readlines(char *lineptr[],int maxlines)
{int len,nlines;
char *p,line[MAXLEN];
nlines=0;
while((len=getline(line,MAXLEN))>0)
if(nlines>=maxlines || p=alloc(len)==NULL)
return -1;
else{line[line-1]='\0';
strcpy(p,line);
lineptr(nlines++)=p;
}
return nlines;
}
The problem is why using this
Code:
strcpy(p,line);
lineptr(nlines++)=p;
instead of this?
Code:
lineptr(nlines++)=line;
What's the difference?