http://www.cplusplus.com/reference/cstring/memset/ memsetvoid * memset ( void * ptr, int value, size_t num ); Fill block of memory Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char).Parameters
Return Valueptr is returned.Example
Output:
memcpyvoid * memcpy ( void * destination, const void * source, size_t num ); Copy block of memory Copies the values of num bytes from the location pointed by source directly to the memory block pointed bydestination.The underlying type of the objects pointed by both the source and destination pointers are irrelevant for this function; The result is a binary copy of the data. The function does not check for any terminating null character in source - it always copies exactly num bytes. To avoid overflows, the size of the arrays pointed by both the destination and source parameters, shall be at leastnum bytes, and should not overlap (for overlapping memory blocks, memmove is a safer approach). Parameters
Return Valuedestination is returned.Example
Output:
memcmpint memcmp ( const void * ptr1, const void * ptr2, size_t num ); Compare two blocks of memory Compares the first num bytes of the block of memory pointed by ptr1 to the first num bytes pointed by ptr2, returning zero if they all match or a value different from zero representing which is greater if they do not.Notice that, unlike strcmp, the function does not stop comparing after finding a null character. Parameters
Return ValueReturns an integral value indicating the relationship between the content of the memory blocks:A zero value indicates that the contents of both memory blocks are equal. A value greater than zero indicates that the first byte that does not match in both memory blocks has a greater value in ptr1 than in ptr2 as if evaluated as unsigned char values; And a value less than zero indicates the opposite. Example
Output:
DWgAOtp12Df0 is greater than DWGAOTP12DF0 because the first non-matching character in both words are 'g' and 'G'respectively, and 'g' (103) evaluates as greater than 'G' (71). strncpychar * strncpy ( char * destination, const char * source, size_t num ); Copy characters from string Copies the first num characters of source to destination. If the end of the source C string (which is signaled by a null-character) is found before num characters have been copied, destination is padded with zeros until a total ofnum characters have been written to it.No null-character is implicitly appended at the end of destination if source is longer than num. Thus, in this case,destination shall not be considered a null terminated C string (reading it as such would overflow). destination and source shall not overlap (see memmove for a safer alternative when overlapping). Parameters
Return Valuedestination is returned.Example
Output:
|
prog | Programming > prog.lang | C++ >