a=(char*) malloc(sizeof(15));		
		b= bmfh.bfType;
		sprintf(a, "bfType:  %d", b);
		TextOut (hdc, 0, 0,a , strlen(a)) ;
			
		delete[] a;
		a=(char*) malloc(sizeof(15));
		b=bmih.biBitCount;
		sprintf(a, "bitCount:  %d", b);
		TextOut (hdc, 0, 20,a , strlen(a)) ;

is it necessary to leave the a undeleted when i gave it another value or i should delete it first and create a new allocation?

thank you

You should definitely deallocate any memory you allocate. Otherwise you'll experience those awful memory leaks.

And why in the world are you using malloc for allocating the memory, and delete for deallocating? That's a bug right there. When in C++, do like the C++'ers do, that is, use new and delete .

whats the difference between malloc and new?

where are they usually used?

>whats the difference between malloc and new? malloc 's for C. new is for C++.

Using C functions in C++ programs is bad enough, but using malloc to allocate something, and delete to deallocate spells pure disaster.

Comments
nice

done. my program is running smoothly. thanks dude.

a rep power for you

>Using C functions in C++ programs is bad enough, but using malloc to allocate something, and delete to deallocate spells pure disaster.

hehehe. cant even tell which functions is c or c++.

just started learning c you know. and im using a visual c++. so basically c code are acceptable.

This question has already been answered. Start a new discussion instead.