Anonymous
public text v1 · immutablevoid GetWordLengths (FILE *p,char **a,int amountOfWords)
{
int i,length=0;
char c=fgetc(p);
for (i=0;i<amountOfWords;i++)
{
if (c!='\n' && c!=EOF)
length++;
else
{
length++; /*the charecter '\0' is a place in the word's array*/
if ((a[i]=(char *) malloc (length*sizeof(char)))==NULL)
{
printf ("allocataion failed\n");
exit (1);
}
length=0;
}
c=fgetc(p);
}
}