Valgrind - facing some problem

This is a discussion on Valgrind - facing some problem within the C++ Programming forums, part of the General Programming Boards category; Hi,
I have the following program
pointertst.cpp
---------
Code:
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main()
{
char *c;
...

Presuming your program really is called "hello.out", and is located in the current directory, you need to specify it as "./hello.out" instead of "hello.out":

Code:

$ valgrind ./hello.out

EDIT: BTW, if you expect Valgrind to produce some kind of warning for this code, it won't. There is no memory leak or out-of-bounds reference happening here. There is a dangling pointer, but Valgrind does not check for those.

Presuming your program really is called "hello.out", and is located in the current directory, you need to specify it as "./hello.out" instead of "hello.out":

Code:

$ valgrind ./hello.out

EDIT: BTW, if you expect Valgrind to produce some kind of warning for this code, it won't. There is no memory leak or out-of-bounds reference happening here. There is a dangling pointer, but Valgrind does not check for those.

Thank you for such quick response.
You have mentioned about dangling pointer. Is it 'c' pointer in the above program you are referring to? If it is then I hope c=NULL will solve the problem?

Thank you for such quick response.
You have mentioned about dangling pointer. Is it 'c' pointer in the above program you are referring to? If it is then I hope c=NULL will solve the problem?

Thanks again!!

Dangling pointers are no problems at all, just things you have to consider. Yes, c = NULL; after free would "fix" this.
I personally don't do this unless NULL is simply a possible value of the pointer that can happen, or where there would be a possibility that I would free/delete the same pointer twice if I don't set it to NULL.

Usually I believe you should just leave a dangling pointer as long as you're smart enough not to use the pointer after freeing it. With the exceptions I mentioned, that is.