Why my code has this warning


  • 0
    S

    C code

    why my code has this warning :

    warning: implicit declaration of function ‘DataFree’ [-Wimplicit-function-declaration]

    but i can do the job on dev c++ correcly

    this is my code and the main()

    #include <stdio.h>
    #include <stdlib.h>
    #include <stdbool.h>
    #include <string.h>
    
    
    struct NumArray {
        int size;
        int* sum;
    };
    
    /** Initialize your data structure here. */
    struct NumArray* NumArrayCreate(int* nums, int numsSize) 
    {
        struct NumArray* create;
        int i;
        int s=0;
        printf("\ncreate");
        create = malloc(sizeof(struct NumArray));
    
        create->size = numsSize;
        create->sum = malloc(sizeof(int) * numsSize);
        printf("\ncreate done1\n");
        for(i=0;i<numsSize;i++)
        {
            s = s + nums[i];
            create->sum[i] = s;
        }
        
        
          
       return create;
    }
    
    int sumRange(struct NumArray* numArray, int i, int j) {
        return numArray->sum[j] - numArray->sum[i];
    }
    
    /** Deallocates memory previously allocated for the data structure. */
    void NumArrayFree(struct NumArray* numArray) {
         printf("\nfree start");
        free(numArray->sum);
        free(numArray);
    }
    
    
    int main(int argc, char *argv[])
    {
        int nums[10] = {0,-1,22,43,14,-5,6,17,18,9};
        int numsSize = 10;
       struct NumArray* vwa = NumArrayCreate(nums, numsSize);
       printf("first:%d",sumRange(vwa, 1, 6));
        // sumRange(numArray, 1, 2);
        NumArrayFree(vwa);
        printf("all done\n");
        system("PAUSE");	
        return 0;
    }

  • 0

    Sorry, just fixed this issue.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.