memccpy() in C++

memccpy(): This function is available in the file string.h. This function copies characters from the object pointed to by src to the object pointed to by dest, stopping after any of the next two conditions are satisfied:

Syntax:

void *memccpy(void *_Dst, const void *_Src, int _Val, size_t _Size)

Parameters

dest: pointer to the object to copy to.

src: pointer to the object to copy from.

c: terminating character, converted to unsigned char at first.

count: number of characters to copy

For Example:

src = "Hello World"

memccpy(dest,src,0,sizeof(src)) = > It copies all characters from source to dest.

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    char str[1000];
    char str1[] = "Hello World";
    memccpy(strstr10sizeof(str1));

    cout << str << "\n";

    return 0;
}


No comments:

Post a Comment