I've enjoyed many of your posts and decided to register and pick your minds if you don't mind.

Somehow I've managed to program for a LONG time and never bothered to understand some things. All too often I've done "just make it work" programming.

I'm working on a program now and noticing things I just think I should understand. For example, here's a line from a program:

note[ctr].nBody = (char *) malloc (100 * sizeof( char ) ) ;

The structure for note is:
Code:
typedef char *STRING

typedef struct noteinfo {	       /* structure of note		*/
	int    nSize;				/* number of characters in note body	*/
	STRING nBody;	 		  /* text of note					*/
	STRING nExtra;			  /* area for extra info such as date string	*/
} NOTEINFO;
So, later when I'm ready to write the file I wanted to test the note body (note[ctr].nBody) to see if it was empty. I expected to be able to see if it was empty by using

Code:
if( note[ctr].nBody == NULL )
But it turns out that there are four chars in .nBody even though I've done nothing with it since the malloc and sizeof() also returns a size of 4.

Can anyone tell me what malloc puts in the string during malloc? And, how might I test note[ctr].nBody to see if it is empty? (Empty meaning nothing has been done to it since the malloc.) I've tested for content using lstrlen(), which returns 0. But that seems kinda sloppy.

Thanks,
Dale L