Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clearing an array

Status
Not open for further replies.

SteveCRM

Programmer
Oct 30, 2000
8
US
how do I clear an array of characters?
 
Put 0 in the first position if array is constant or call delete[] if allocated. John Fill
1c.bmp


ivfmd@mail.md
 
I have always used memset

Example

char myArray[256];
... // some code that fills the array

// here is how i empty it
memset(myArray,0,sizeof(myArray));

the "0" in memset is what I am setting every character in the array to so if you wanted to put something else in there, such as all one letter, use the ascii equivalent

Matt
 
Why set all characters to 0? Too much to work. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top