Hi All,

I am facing problems with free() API of ANSI.
I am using Visual Studio 2005. I am using 2 char pointers. If i copy from one to another and after if i try to free source pointer, it is giving exception. How to debug this problem?

Please help me anybody.

If you're seeing a runtime error inside free, it means you corrupted the memory. Verify that you're allocating enough memory, then make sure you don't access that memory out of bounds. There's nothing wrong with the free function itself.

If you post the code that is causing you problems someone may be able to help

for one thing, you dont "free" a pointer. you free previously allocated memory space.

that you're talking about freeing a pointer, makes me suspect you didn't allocate the memory in the first place.

of course it's all speculation at this point, since you haven't posted any code for us to look at.

>for one thing, you dont "free" a pointer.
You're correct, pedantically speaking, but programmers typically don't speak pedantically unless they're trying to avoid annoying nitpickers. It's perfectly reasonable to say you're freeing a pointer, and the statement doesn't indicate either lack of understanding or the presence of bugs.

>makes me suspect you didn't allocate the memory in the first place.
That's one possibility, but the way you reached the conclusion is nonsensical.

okay. point taken.

but i said "suspect" not "conclusion"

and im still waiting for code.