Thread: Points system

  1. #1
    Registered User
    Join Date
    Jan 2003

    Points system

    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))
    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...

    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)

    while( fgets(pointstemp, 256, pp) != NULL)
    if ((strstr(pointstemp, pointsword)) !=NULL)
    printf("Line number containing %s is %d\n", pointsword, linepoint);


    printf("Number of lines is %d\n", linepoint);

    if (findpoint == 0)
    printf("\nNo match found.\n");


    return 0;

  2. #2
    Join Date
    Aug 2001
    Groningen (NL)
    The function points() needs to be of a certain type, for example:

    int points()

    You cannot use function points like this:


    If you want to pass that value to points, then to this as follows:

    Declare function as: int points (int p);
    Use function as: points (100);

    Also function points() seems to return an error value, it would be recommendable to check this value. Like:

    result = points (100);
    if (result == -1)
    /* do some error handling */

    If you open a file using fopen(), then you must close it when you are done with the file using fclose().

  3. #3
    Registered User
    Join Date
    Jan 2003
    Thanks very much for your help, have got the code working now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 07:56 PM
  2. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  3. measuring system resources used by a function
    By Aran in forum C Programming
    Replies: 1
    Last Post: 03-13-2006, 05:35 PM
  4. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 07:12 AM
  5. Problem Reporting System. Need Advide!
    By brunomiranda in forum Tech Board
    Replies: 9
    Last Post: 09-25-2003, 09:21 PM