Since you are using a simple array, you had to declare its size in your program, so you already know the size of the array, and you should use that in your loop. For instance:
Code:
const int size = 10;
char myArray[size] = "hello";
...
...
for(int i=0; i<size; i++)
{
}
Also, as was mentioned, you might not need to erase the array because you can do this:
Code:
char myArray[10] = "hello";
strcpy(myArray, "hi");
cout<<myArray<<endl;
If you were using string types, you could do this:
Code:
string myStr = "hello world";
myStr = "";