Hi all,
Background - Am trying to allocate a file a number of points depending on how relavent it it to a word entered by a user. At present the program finds which line the word occurs on and also how many lines there are in the file.
Aim - To divide the program up into 10 sections (ie. divide linepoint by 10) and allocate 100 points for each time the word occurs in the first 10% of the code and then 90 points for each time the word occurs in the first 20% of the code and so on.
At present am having problems as was trying to say:
if ((strstr (pointstemp, pointsword))==((linepoint/100)*10))
{
points=100;
}
but threw up warnings are i was trying to compare a char and an int and so was not working effectively.
Any ideas would be greatly appreciated as am having serious problems with this. Thanks very much in advance.
My code so far is...
points()
{
FILE *pp;
int findpoint=0;
int linepoint=1;
char pointstemp[256];
char pointsfilename[25];
char pointsword[25];
printf("Please enter file name: ");
scanf("%s", pointsfilename);
printf("Please enter word: ");
scanf("%s", pointsword);
if ((pp = fopen(pointsfilename, "r")) == NULL)
return(-1);
while( fgets(pointstemp, 256, pp) != NULL)
{
if ((strstr(pointstemp, pointsword)) !=NULL)
{
printf("Line number containing %s is %d\n", pointsword, linepoint);
findpoint++;
}
linepoint++;
}
printf("\n");
printf("Number of lines is %d\n", linepoint);
if (findpoint == 0)
{
printf("\nNo match found.\n");
}
printf("\n\n");
menu();
return 0;
}