To represent the fact that the value is not present you have two choices:
1) If the whole char
range is meaningful and you cannot reserve any value, then use char*
instead of char
:
char** c = new char*[N];
c[0] = NULL; // no character
*c[1] = ' '; // ordinary character
*c[2] = 'a'; // ordinary character
*c[3] = '\0' // zero-code character
Then you'll have c[i] == NULL
for when character is not present and otherwise *c[i]
for ordinary characters.
2) If you don't need some values representable in char
then reserve one for indicating that value is not present, for example the '\0'
character.
char* c = new char[N];
c[0] = '\0'; // no character
c[1] = ' '; // ordinary character
c[2] = 'a'; // ordinary character
Then you'll have c[i] == '\0'
for when character is not present and ordinary characters otherwise.