Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Clearing Arrays In C

2007-04-17 by dlc@frii.com

How about memset?

void * memset ( void * ptr, int value, size_t num );

usage:

#include <stdio.h>
#include <string.h>

int main ()
{
  memset (str,'-',6);
}

DLC

> Hi guys,
>
> I was writing some software for a scrolling message board when I came
> across the problem of clearing arrays during run-time in C.
>
> Usually I do something like:
>
> unsigned char array1[100];
> unsigned char count;
>
> for (count = 0; count < 100; count++){
>
>   array1[count] = 0;
> }
>
> Has anybody ever come across a faster or more interesting way of
> accomplishing this ?
>
> Cheers
> Hein B
> Auckland, New Zealand
>
>
>
>
> Yahoo! Groups Links
>
>
>
>

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.