clearing array elements?
I have a character array:
slots 0-9 are filled in the array..I want to clear the array so brand new character can be entered in there place. How would I go about doing this?
Two ways immediately come to mind.
To write over all the elements of the array with a NULL (value of zero), you could either use a loop or use memset:
Or, if you just want to make it an empty string:
memset(test, 0, 10);
In this second case, it doesn't matter that the previous characters are still in the array, because the string ends at the NULL.
third: just enter the new char's in the array. They don't mind if there's a '\0' there or some other char.
Last edited by 7stud; May 10th, 2003 at 02:35 AM.