GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
STRMAXCPY(3) C Programmer's Manual STRMAXCPY(3)

strmaxcpy - copy at most a given number of characters of string

#include <publib.h>
char *strmaxcpy(char *tgt, const char *src, size_t n);

strmaxcpy copies up to n-1 characters from the beginning of src to tgt, then adds a '\0'. n must be at least 1. The target string must be large enough to hold the result.

Note that unlike strncpy(3), this function always terminates the result with '\0'. It also doesn't fill the result with extra '\0' characters.

strmaxcpy returns its first argument.

To print out the first 69 characters of a string, you might do the following (although familiarity with printf's format string might be more useful in this case).


#include <stdio.h> #include <publib.h> void print42(const char *string) { char copy[43]; /* 42 + '\0' */ puts(strmaxcpy(copy, string, sizeof(copy))); }

publib(3), strncpy(3)

Lars Wirzenius (lars.wirzenius@helsinki.fi)
C Programmer's Manual Publib

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.