char* strncpy(char* cpDest, const char* kcpSrc, size_t qCount);
#include <cstdio> #include <cstring> int main() { char caSource[] = "XoaX.net"; char caDest[20]; // Copy the first chars of "XoaX.net" strncpy(caDest, caSource, 4); // Add a null-terminator for printing caDest[4] = '\0'; printf("Copied: %s\n", caDest); return 0; }
© 20072024 XoaX.net LLC. All rights reserved.