Advertisement

Clearing an Array

Started by July 28, 2000 05:03 PM
3 comments, last by KalvinB 24 years, 4 months ago
What is the easiest way to clear an array without using for loops? Ben
quote: Original post by KalvinB

What is the easiest way to clear an array without using for loops?



Well, you haven''t told us in which language the stuff should be done.

Notice that "for loop" is just an iteration. I really don''t think you can clear an array without doing iteration at all...

However, in ANSI C you could use the memset() function... of course it does some kind of iteration to clear the array, but you haven''t to code it by yourself.


Karmalaa

---[home page] [[email=karmalaa@inwind.it]e-mail[/email]]
Advertisement
Whats wrong with a for loop?

+---------------------------------------------
Help me program my 3d game
I just got a new copy of Lear C++ in 21 days!
+---------------------------------------------
Those who dance are considered insane by those who cannot hear the music.
If you''re programming for Win32, ZeroMemory is a handy function. And if you''re just clearing an array, coding a for loop takes a few seconds longer and is slightly more error prone than calling a function.


- Democritus

* Truth is universal *

- Democritus * Truth is universal *
quote: Original post by Democritus

If you're programming for Win32, ZeroMemory is a handy function. And if you're just clearing an array, coding a for loop takes a few seconds longer and is slightly more error prone than calling a function.


- Democritus

* Truth is universal *



It's Win32 and sweet. Took 15 seconds compared to 10 minutes with for loops. That was the reason. In order to speed up the map loading time I had to avoid writing 0s.

ZeroMemory(↦,sizeof(map);

Ben


Edited by - KalvinB on July 28, 2000 8:12:17 PM

This topic is closed to new replies.

Advertisement