All pastes #571739 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-06-17 09:14 UTC
rendered paste body
void 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);
	}
}