0

Hi im getting a symbol NULL not resolved error I have tried saving, cleaning and building the project again. Also I have tried closing and restarting Eclipse. I have included libraries I believe I will need and more but Ive got 13 of these errors plus one stderr not resolved error as well can anyone point out my issue here. I was going to post the picture but my rep isnt high enough.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stddef.h>

#define PUNC    " \t\n\r,;.:!()[]{}?'\""
typedef struct node node;

typedef struct node {
    char *word;
    int count;
    node *left;
    node *right;
} node;
void insert( node ** dictionary, char * word ) {
    int result;
    node * entry;
        if ( word == NULL || dictionary == NULL ) return;
        if ( *dictionary == NULL ) {
            entry= (node *) malloc( sizeof( node ) );
            strcpy( entry->word= (char *) malloc( strlen( word ) + 1 ), word );
            entry->left= entry->right= NULL;
            entry->count= 1;
            *dictionary= entry;
            return;
        }
        result= strcmp( word, (*dictionary)->word );
        if ( result < 0 )
            insert( &(*dictionary)->left, word );
        else if ( result > 0 )
            insert( &(*dictionary)->right, word );
        else
            ++(*dictionary)->count;
    return;
}
void printDictionary( node * dictionary ) {
        if ( dictionary == NULL ) return;
        printDictionary( dictionary->left );
        printf( "%s = %d\n", dictionary->word, dictionary->count );
        printDictionary( dictionary->right );
    return;
}
void freeDictionary( node ** dictionary ) {
        if ( dictionary == NULL || *dictionary == NULL ) return;
        freeDictionary( &(*dictionary)->left );
        freeDictionary( &(*dictionary)->right );
        free( (*dictionary)->word );
        free( *dictionary );
        *dictionary= NULL;
    return;
}
int main( int argc, char *argv[] ) {
    FILE *fp;
    char b[1000], *s;
    node *dictionary= NULL;
    int i;
        for ( i= 1; i < argc; ++i ) {
            if ( (fp= fopen( argv[i], "r" )) == NULL ) {
                fprintf( stderr, "File %s can not be opened.\n", argv[i] );
                continue;
            }
            for( s= fgets( b, sizeof(b), fp ); s != NULL; s= fgets( b, sizeof(b), fp ) ) {
                char *word;
                for ( word= strtok( b, PUNC ); word != NULL; word= strtok( NULL, PUNC ) )
                    insert( &dictionary, strlwr( word ) );
            }
            fclose( fp );
        }
        printDictionary( dictionary );
        freeDictionary( &dictionary );
    return 0;
}
Silent Phantom
  • 113
  • 1
  • 1
  • 6
  • 2
    Have you tried google? http://stackoverflow.com/questions/10955343/eclipse-cdt-c-null-not-resolved – Leeor Sep 22 '13 at 18:07
  • possible duplicate of [Eclipse CDT "Symbol NULL could not be resolved"](http://stackoverflow.com/questions/7433448/eclipse-cdt-symbol-null-could-not-be-resolved) – anatolyg Sep 22 '13 at 18:09
  • This does *not* appear to be a duplicate of http://stackoverflow.com/questions/10955343/eclipse-cdt-c-null-not-resolved. In that question, `NULL` could not be resolved because no header that defines it had been `#include`d. In this question, all the required headers are `#include`d. – Keith Thompson Sep 22 '13 at 20:58
  • Are you *sure* you got that specific error with that specific code? When I compile your code (using gcc), it doesn't complain about `NULL`, though it does warn about a few other things. Are you certain that you're actually compiling the code you think you are? – Keith Thompson Sep 22 '13 at 21:00
  • And please don't post a screenshot from Eclipse; instead, copy-and-paste the *text* of the error message. – Keith Thompson Sep 22 '13 at 21:02
  • @KeithThompson Thanks for the forum advice but I just hit run and all the errors went away I dont know why but im not complaining. Thanks everybody. – Silent Phantom Sep 22 '13 at 23:43

0 Answers0