久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

我可以用“字節數"調用 memcpy() 和 memmove() 嗎

Can I call memcpy() and memmove() with quot;number of bytesquot; set to zero?(我可以用“字節數調用 memcpy() 和 memmove() 嗎?設置為零?)
本文介紹了我可以用“字節數"調用 memcpy() 和 memmove() 嗎?設置為零?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

當我實際上沒有什么可移動/復制的情況時,我是否需要將 memmove()/memcpy() 作為邊緣情況處理

Do I need to treat cases when I actully have nothing to move/copy with memmove()/memcpy() as edge cases

int numberOfBytes = ...
if( numberOfBytes != 0 ) {
    memmove( dest, source, numberOfBytes );
}

或者我應該直接調用函數而不檢查

or should I just call the function without checking

int numberOfBytes = ...
memmove( dest, source, numberOfBytes );

是否需要檢查之前的代碼片段?

Is the check in the former snippet necessary?

推薦答案

來自 C99 標準 (7.21.1/2):

From the C99 standard (7.21.1/2):

聲明為 size_t n 的參數指定數組的長度函數,n 在調用該函數時可以具有零值.除非明確說明否則在本小節中對特定函數的描述中,指針參數此類調用仍應具有有效值,如 7.1.4 中所述.在這樣的電話中,一個定位一個字符的函數沒有找到,一個比較兩個字符的函數字符序列返回零,復制字符的函數復制零字符.

Where an argument declared as size_t n specifies the length of the array for a function, n can have the value zero on a call to that function. Unless explicitly stated otherwise in the description of a particular function in this subclause, pointer arguments on such a call shall still have valid values, as described in 7.1.4. On such a call, a function that locates a character finds no occurrence, a function that compares two character sequences returns zero, and a function that copies characters copies zero characters.

所以答案是否定的;不需要檢查(或者是;您可以通過零).

So the answer is no; the check is not necessary (or yes; you can pass zero).

這篇關于我可以用“字節數"調用 memcpy() 和 memmove() 嗎?設置為零?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡單指針的區別?)
Difference between const. pointer and reference?(常量之間的區別.指針和引用?)
How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪問向量的內容?)
Meaning of *amp; and **amp; in C++(*amp; 的含義和**amp;在 C++ 中)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對普通變量進行多態?)
Dereferencing deleted pointers always result in an Access Violation?(取消引用已刪除的指針總是會導致訪問沖突?)
主站蜘蛛池模板: 性欧美精品一区二区三区在线播放 | 91亚洲国产成人久久精品网站 | 91xxx在线观看 | 国产精品国产三级国产aⅴ中文 | 久久久国产精品网站 | 精品久久香蕉国产线看观看亚洲 | 精品在线一区二区 | 一区二区三区高清 | 久久婷婷香蕉热狠狠综合 | 亚洲综合色网 | 国产精品九九九 | 精品亚洲永久免费精品 | 日韩aⅴ视频| 免费看淫片 | 日本午夜在线视频 | 一区二区三区在线播放 | 精品一区二区三区在线视频 | 亚洲国产精品日本 | 久草网站 | 国产婷婷色综合av蜜臀av | 粉嫩一区二区三区性色av | 欧美日韩精品 | 久久久久国产精品www | 国产特级毛片 | 成人精品免费视频 | 超碰人人人 | 羞羞网站在线观看 | 国产剧情久久 | 亚洲成人av在线播放 | 亚洲高清视频在线 | 国产日韩一区 | 欧美一区视频 | 9久久婷婷国产综合精品性色 | 黄色毛片在线观看 | 午夜精品一区二区三区在线观看 | 国产欧美精品一区二区三区 | 亚洲精品久久久久久久久久久久久 | 久久国产精品无码网站 | 91视频在线 | 日韩网| 日韩在线中文字幕 |