Windows network programming c language error: [Error] 'bzero' was not declared in this scope

Please take a look before reading: I am a person who is keen on recording. Every time I write a blog, I will study it repeatedly and try my best to continuously improve the quality of the blog. The article is set to only fans, because blogging really took a lot of effort. Hope to improve each other Thank you! !


提示:以下是本篇文章正文内容

1. Problem description

background

For network programming under windows, devc++ runs the cpp program, and the error code is as follows:

bzero(&icmp, sizeof(icmp));

bug

[Error] ‘bzero’ was not declared in this scope

As shown below:

insert image description here


2. Solutions

Now bzero() is not part of the standard library and is now deprecated, so consider using memset(), and of course ZeroMemory(). The specific usage of the two functions can be done by Baidu

The specific code is replaced as follows:

bzero(&icmp, sizeof(icmp));          //报错
ZeroMemory(&icmp, sizeof(icmp));     //不报错
memset(&icmp, 0, sizeof(icmp));      //不报错

Code words are not easy, thank you for your praise! ! !
Code words are not easy, thank you for your praise! ! !
Code words are not easy, thank you for your praise! ! !

Guess you like

Origin blog.csdn.net/qq_40967086/article/details/128491701