|Looking at your statement:|
char array = "\0";
What does it actually do? An auxilliary question, how big an
array does it declare? char array means you are not
specifying the size, but it takes the size from the initializer: =
So what exactly is the type and size of "\0"? Answer: it is a
two-element array, containing two NUL characters. Why?
First, the empty string "" is a one-element array containing
the NUL terminator. Any string literal, say "a", ends with a
NUL terminator. So "\0" both contains a NUL character and is
followed by another NUL character.
So you have declared a two-element array. Is that what you
want? When you input a word like "function", how do you
protect against overwriting memory past the array elements
that you have allocated?
Next, when you say you "reinitialize it as empty the second
time through" what exactly do you mean by empty? A char
array is a fixed size. It has the size that you allocated for it at
the start. By convention, a NUL character is often treated as a
string terminator, so you can think of an array starting with
the NUL character as an empty string. To do that, you need
to do this:
array = '\0';
Also, notice the crucial difference between '\0' and "\0".