Re: set structure element to zero

Scott Henion <[email protected]>
Newsgroups gmane.comp.hardware.rabbit-semiconductor
Message-ID <[email protected]>
On 3/7/2014 10:55 AM, [email protected] wrote:
> Hello, 
>
> I have some structure variables, Each structure has some elements,
> some are used in the program;others are not used and reserved for the
> future. When I start the program, I would like to set all elements to
> zero value. Anybody know some fast way to do it? I am using BL4S200;

Use memset to fill with zeros.

struct MyStruct mydata;
.....
    memset(&mydata,0,sizeof mydata);

-- 
------------------------------------------
     Scott G. Henion, Consultant
Web site:    http://SHDesigns.org
------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.