# strncpy function

strncpy copies 'n' bytes from one string to another.

    Library:   string.h

    Prototype: char strncpy(char s1, const char *s2, size_t n);

    Syntax:	   size_t n;
    	   char string1[20]="red dwarf";
    	   char string2[20]=";
               strncpy(string2, string1, 4);

## Notes

- It may be nessacary to add your own NULL terminator.

example program.

An alternative method using 'sprintf'...

## See also:

- strcpy Copy a string.
- memcpy Copy memory.
- strtok Get characters upto a seperator.
- strcasecmp Compare strings, ignoring case.

Top | Master Index | Keywords | Functions