std::memcpy 您所在的位置:网站首页 幼儿园小班科学教学反思范文大全 std::memcpy

std::memcpy

2023-02-24 11:45| 来源: 网络整理| 查看: 265

  C++ Compiler support Freestanding and hosted Language Standard library Standard library headers Named requirements Feature test macros (C++20) Language support library Concepts library (C++20) Metaprogramming library (C++11) Diagnostics library General utilities library Strings library Containers library Iterators library Ranges library (C++20) Algorithms library Numerics library Localizations library Input/output library Filesystem library (C++17) Regular expressions library (C++11) Concurrency support library (C++11) Technical specifications Symbols index External libraries [edit]  Strings library Null-terminated strings Byte strings Multibyte strings Wide strings Classes basic_string basic_string_view(C++17) char_traits [edit]  Null-terminated byte strings Functions Character manipulation isalnum isalpha islower isupper isdigit isxdigit isblank(C++11)     iscntrl isgraph isspace isprint ispunct tolower toupper Conversions to numeric formats atof atoiatolatoll(C++11) strtolstrtoll(C++11) strtoulstrtoull(C++11) strtofstrtodstrtold(C++11)(C++11) strtoimaxstrtouimax(C++11)(C++11) String manipulation strcpy strncpy strxfrm strcat strncat String examination strlen strcmp strncmp strcoll strchr strrchr strspn strcspn strpbrk strstr strtok Memory manipulation memchr memcmp memset memcpy memmove Miscellaneous strerror [edit]  Defined in header void* memcpy( void* dest, const void* src, std::size_t count );

Copies count bytes from the object pointed to by src to the object pointed to by dest. Both objects are reinterpreted as arrays of unsigned char.

If the objects overlap, the behavior is undefined.

If either dest or src is an invalid or null pointer, the behavior is undefined, even if count is zero.

If the objects are potentially-overlapping or not TriviallyCopyable, the behavior of memcpy is not specified and may be undefined.

Contents 1 Parameters 2 Return value 3 Notes 4 Example 5 See also [edit] Parameters dest - pointer to the memory location to copy to src - pointer to the memory location to copy from count - number of bytes to copy [edit] Return value

dest

[edit] Notes

std::memcpy may be used to implicitly create objects in the destination buffer.

std::memcpy is meant to be the fastest library routine for memory-to-memory copy. It is usually more efficient than std::strcpy, which must scan the data it copies or std::memmove, which must take precautions to handle overlapping inputs.

Several C++ compilers transform suitable memory-copying loops to std::memcpy calls.

Where strict aliasing prohibits examining the same memory as values of two different types, std::memcpy may be used to convert the values.

[edit] Example Run this code #include #include #include   int main() { // simple usage char source[] = "once upon a midnight dreary...", dest[4]; std::memcpy(dest, source, sizeof dest); std::cout


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有