GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::strcpy(3) C++ Standard Libary std::strcpy(3)

std::strcpy - std::strcpy


Defined in header <cstring>
char* strcpy( char* dest, const char* src );


Copies the character string pointed to by src, including the null terminator, to the
character array whose first element is pointed to by dest.


The behavior is undefined if the dest array is not large enough. The behavior is
undefined if the strings overlap.


dest - pointer to the character array to write to
src - pointer to the null-terminated byte string to copy from


dest

// Run this code


#include <iostream>
#include <cstring>
#include <memory>


int main()
{
const char* src = "Take the test.";
// src[0] = 'M'; // can't modify string literal
auto dst = std::make_unique<char[]>(std::strlen(src)+1); // +1 for the null terminator
std::strcpy(dst.get(), src);
dst[0] = 'M';
std::cout << src << '\n' << dst.get() << '\n';
}


Take the test.
Make the test.


strncpy copies a certain amount of characters from one string to another
(function)
memcpy copies one buffer to another
(function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.