0

I am writing the following code on visual studio 2013

#include "malloc.h"
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "stdafx.h"
#include <assert.h>

void deltree(Node * n)
{
    if (n)
    {
        deltree(n->left);
        deltree(n->right);
        free(n);

    }
}

it doesnt work and it says "error C3861: 'free': identifier not found" any idea?

Telokis
  • 3,399
  • 14
  • 36
Mohammed
  • 334
  • 1
  • 5
  • 22
  • 4
    Could you show us your malloc.h ? Do you have any other definition of free somewhere ? – Telokis Mar 08 '15 at 20:05
  • 11
    Either remove that [`"stdafx.h"` weirdness](http://stackoverflow.com/questions/2976035), or include it before anything else. Apparently, the compiler ignores anything before that (including your inclusion of ``, hence the error). – Mike Seymour Mar 08 '15 at 20:25
  • It seems to be C and not C++. THe tags should be adjusted. – Christophe Mar 08 '15 at 20:44
  • Choose your language, C or C++. For c++ you should use `new` and `delete`, while they don't exist in the C language. – Thomas Matthews Mar 08 '15 at 21:34
  • Your title says `Free`, but the code in the question says `free`. Which is it? (They're two distinct identifiers.) BTW, you don't need `"malloc.h"`; both `malloc` and `free` are declared in ``. – Keith Thompson Mar 09 '15 at 02:18
  • Where, I wonder, is `Node` defined? Presumably, it must either be `malloc.c` or `stdafx.h` since none of the other headers normally defines it. – Jonathan Leffler Mar 09 '15 at 02:40

0 Answers0