maybe pDot = NULL; or pDot = (char*)NULL;
To "empty" the array try CurScheme[0]='\0';
The array isn't really empty, but when you output it it will look like empty, because \0 is a "terminator"
upcase
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-02-14
An array can never be 'empty', it is memory, it must contain something. If CurScheme is a string, then setting element [0] to '\0' will terminate it. If it is simply an array of chars then you can initialize the array to any value with memset().
// init CurScheme[] to all zero.
memset( CurScheme, sizeof(CurScheme), 0 ) ;
Simply setting pDot to NULL or zero will suffice, since it is illegal to dereference a null pointer in C/C++. A run-time error occurs if you attempt it, but you can test the pointer for NULL or zero to check if it is initialised or not.
Note that ant static variables are always automatically initialised to zero, so if you declare static or glovbal data you can rely on this aspect of C/C++.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I got this two vars in my program inside a function,
char *pDot;
char CurScheme[61];
I need to be sure that at some point of my program CurScheme is empty and *pDot points to nothing. How can that be done?
Thanks in advance
maybe pDot = NULL; or pDot = (char*)NULL;
To "empty" the array try CurScheme[0]='\0';
The array isn't really empty, but when you output it it will look like empty, because \0 is a "terminator"
upcase
An array can never be 'empty', it is memory, it must contain something. If CurScheme is a string, then setting element [0] to '\0' will terminate it. If it is simply an array of chars then you can initialize the array to any value with memset().
// init CurScheme[] to all zero.
memset( CurScheme, sizeof(CurScheme), 0 ) ;
Simply setting pDot to NULL or zero will suffice, since it is illegal to dereference a null pointer in C/C++. A run-time error occurs if you attempt it, but you can test the pointer for NULL or zero to check if it is initialised or not.
Note that ant static variables are always automatically initialised to zero, so if you declare static or glovbal data you can rely on this aspect of C/C++.