About 305,000 results
Open links in new tab
  1. c++ - Proper way to copy C strings - Stack Overflow

    Mar 7, 2012 · If you really do find that std::string is unusable, consider std::array<char,MAX+1>: a copyable class containing a fixed-size array. If stringB is checked for equality with other C-strings, …

  2. How to copy a string of std::string type in C++? - Stack Overflow

    97 You shouldn't use strcpy() to copy a std::string, only use it for C-Style strings. If you want to copy a to b then just use the = operator.

  3. Copying a part of a string (substring) in C - Stack Overflow

    Jan 22, 2010 · strncpy: This function is used to copy a specified number of characters from the source string to the destination string. In this case, it copies the substring from the source string.

  4. c - what is the most efficient way to copying a string?

    Jan 20, 2022 · The efficiency of a while loop vs. a for loop is in the "sunk cost" category -- the savings won't vary with the string length. As Peter Cordes said, memcpy () is tough to improve on, but …

  5. c - How to copy a string using a pointer - Stack Overflow

    How to copy a string using a pointer Asked 12 years, 2 months ago Modified 7 years, 9 months ago Viewed 93k times

  6. Implementing a string copy function in C - Stack Overflow

    My point is that there aren't many times when you are okay with getting a possibly truncated string copied. In this case, for example, you would know the length of the source string and allocate the …

  7. c string copy with strncpy - Stack Overflow

    Sep 23, 2011 · When you read the string back you're reading past the end of your buffer. Make final 33 bytes long, and ALWAYS add a NUL to the last character in the destination when using strncpy.

  8. Given a starting and ending indices, how can I copy part of a string in C?

    In C, how can I copy a string with begin and end indices, so that the string will only be partially copied (from begin index to end index)? This would be like 'C string copy' strcpy, but with a begin and an …

  9. Allocate memory and save string in c - Stack Overflow

    Dec 22, 2011 · Instead of changing the pointer test, you need to copy the string "testingonly" into the allocated place using e.g. strcpy or use strdup. Note that functions like malloc and strdup return …

  10. What's the use of System.String.Copy in .NET? - Stack Overflow

    56 With String.Copy you are actually allocating new memory and copying the characters from one string to another; you get a completely new instance as opposed to having both variables being the same …