Terry said:
I have an array that I initialize to zero, like:
Buffer[300] = {0x00};
How do I in my code reset this array to all zeros ones more? Without running
a whole for loop?
Best Regards
Terry
If you can put it inside a structure, you could create a zero-filled
instance and assign your buffer to that, e.g. this:
#include<stdio.h>
#include<string.h>
#define BUFFSIZE 9
typedef struct {
int Buffer[BUFFSIZE];
} BUFFSTRUCT;
static const BUFFSTRUCT ZeroBuffStruct;
void prtBuf(int buf[])
{
int i;
for (i=0; i<BUFFSIZE; i++)
printf("%d",buf
);
printf("\n");
}
int main()
{
BUFFSTRUCT BufStruct;
int *Buffer = BufStruct.Buffer;
BufStruct = ZeroBuffStruct;
prtBuf(Buffer);
Buffer[3] = 4;
prtBuf(Buffer);
BufStruct = ZeroBuffStruct;
prtBuf(Buffer);
return 1;
}
produces the output:
Buffer="00000000"
Buffer="00040000"
Buffer="00000000"
If that's non-portable or has other problems, I'm sure someone will let
us know....
Regards,
Ed.