![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
Flushing out an array (solved)
How can you flush out an array? So it would have no values.
Last edited by navnav; Jun 28th, 2005 at 12:35 PM. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
An array is a series of contiguous memory locations. These are typically little silicon hardware thangies that have their bit storage mechanisms in one state or another: zero (off) or one (on). They never have NO values. They may have unknown values, but values are there. The best you can do is initialize them to some known value which, to YOU, represents nada. A universally useful value for that does not exist since all values are subject to interpretation of one kind or another, depending up their presumed "type".
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
You can use the memset() function. Here's a link.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
|
nnxion, thanks that worked perfectly
![]() True, but this is a char array im dealing with (should of said that before), so how would it be possible to set it all to 0 without the header <string.h>? |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: here
Posts: 152
Rep Power: 4
![]() |
int i = 0; char val = '\0'; /* here val represents the value you want to assign */ for (;i < length_of_the_array; ++i) your_array[i] = val;
__________________
"...and though our kids are blessed their parents let them shoulder all the blame." - The Quiet Things That No One Ever Knows [BrandNew] |
|
|
|
|
|
#6 |
|
Hobbyist Programmer
|
OK thanks. Solved
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|