Thread: Comparison between pointer and integer

  1. #1
    Registered User
    Join Date
    Oct 2019
    Posts
    16

    Comparison between pointer and integer

    I am running into an error that states:
    warning: comparison between pointer and integer
    230 | while (currentWord != NULL && wordCountChoice > currentWord->count)


    When running this code:
    Code:
    currentWord = wordptr;
        wordCountChoice;
        while (currentWord != NULL && wordCountChoice > currentWord->count)
        { 
            //prints as word,# where # is the word occurance count
            fprintf (outputFile, "%s,%d \n", currentWord->str, currentWord->count);
            printf ("%s",currentWord->str);
            currentWord = currentWord->next;
        }
    If I have written this code correctly then the objective of the code is to only display words from a doubly linked list that have a word count greater or equal to the users wordCountChoice.
    Any help is appreciated.

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,192
    wordCountChoice should be an integer, not a char* if that's what it is.
    You can convert the string input to an integer with atoi().
    Also note that line 2 above does nothing.
    We live as it were by chance, and by chance we are governed. - Seneca

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Comparison between pointer and integer
    By Thedon in forum C Programming
    Replies: 7
    Last Post: 11-12-2011, 01:09 PM
  2. Comparison between pointer & integer
    By m88g88 in forum C Programming
    Replies: 5
    Last Post: 02-16-2010, 05:25 PM
  3. comparison pointer and integer
    By plodos in forum C Programming
    Replies: 19
    Last Post: 01-09-2009, 08:51 AM
  4. comparison between pointer and integer
    By R.Stiltskin in forum C Programming
    Replies: 13
    Last Post: 03-24-2007, 02:33 PM
  5. comparison between pointer and integer
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 03-07-2006, 01:15 PM

Tags for this Thread