Prototype: extern char * strncpy (char * DEST, char * SRC, int N); usage: # include <string. h> function: copy the first n Bytes of the string ending with null in SRC to the array indicated by DeST. Note: If the first n Bytes of SRC do not contain null characters, the result will not end with null characters. If the SRC length is less than n Bytes, fill the Dest with null until the n Bytes are completely copied. The memory areas specified by Src and DEST cannot overlap and DEST must have enough space to hold SRC strings. Returns the pointer to DeST. Example: // strncpy. C # include <syslib. h> # include <string. h> main () {char * s = "golden Global View"; char * D = "Hello, ggv programmers"; char * P = strdup (s); clrscr (); textmode (0x00); // enable 6 lines mode strncpy (D, S, strlen (s); printf ("% s \ n", d ); strncpy (P, S, strlen (d); printf ("% s", P); getchar (); Return 0 ;}
Stpcpy |
|
Prototype: extern char * stpcpy (char * DEST, char * SRC); usage: # include <string. h> function: copy the string ending with null indicated by Src to the array indicated by DeST. Note: The memory areas specified by Src and DEST cannot overlap and DEST must have sufficient space to accommodate SRC strings. Returns the pointer pointing to the end of the Dest character (null. Example: // stpcpy. C # include <syslib. h> # include <string. h> main () {char * s = "golden Global View"; char d [20]; clrscr (); stpcpy (D, S); printf ("% s ", d); getchar (); Return 0 ;} |
Memcpy |
|
Prototype: extern void * memcpy (void * DEST, void * SRC, unsigned int count); usage: # include <string. h> function: copy count bytes from the memory area indicated by Src to the memory area indicated by DeST. Note: the memory areas specified by Src and DEST cannot overlap. The function returns a pointer to DeST. Example: // memcpy. C # include <syslib. h> # include <string. h> main () {char * s = "golden Global View"; char d [20]; clrscr (); memcpy (D, S, strlen (s )); d [strlen (s)] = 0; printf ("% s", d); getchar (); Return 0 ;} |
Strcpy |
|
Prototype: extern char * strcpy (char * DEST, char * SRC); usage: # include <string. h> function: copy the string ending with null indicated by Src to the array indicated by DeST. Note: The memory areas specified by Src and DEST cannot overlap and DEST must have sufficient space to accommodate SRC strings. Returns the pointer to DeST. Example: // strcpy. C # include <syslib. h> # include <string. h> main () {char * s = "golden Global View"; char d [20]; clrscr (); strcpy (D, S); printf ("% s ", d); getchar (); Return 0 ;} |
Memccpy |
|
Prototype: extern void * memccpy (void * DEST, void * SRC, unsigned char CH, unsigned int count); usage: # include <string. h> function: the data is copied from the memory area indicated by Src to the memory area indicated by DeST. If the CH character is encountered, the data is stopped. Note: The pointer pointing to the first character after the CH character is returned. If ch does not exist in the First n Bytes of SRC, null is returned. Ch is copied. Example: // memccpy. C # include <syslib. h> # include <string. h> main () {char * s = "golden Global View"; char d [20], * P; clrscr (); P = memccpy (D, S, 'X', strlen (s); If (p) {* P = '\ 0'; // must do this printf ("char found: % S. \ n ", d);} else printf (" char not found. \ n "); getchar (); Return 0 ;} |
|
|
|
|
|