Private: 私有的:strncat

bigzhu posted @ Nov 26, 2007 08:01:00 PM in cpp , 1345 阅读

char *  strncat ( char * dest, const char * src, sizet_t num );

Append substring to string.
Appends num characters of src string to dest string. If the terminating null-character appears in src string before num character have been appended, the function appends the null-character to dest and ends.
The terminating null character in dest is overwritten by the first character of src. The resulting string includes a null-character at end.

Parameters.

dest
Pointer to a null-terminated string with enough space allocated to contain src plus num characters.
src
Null-terminated string containing characters to be appended.
num
Number of characters to be appended from src to dest.

Return Value.
dest is returned.

Portability.
Defined in ANSI-C.

Example.

/* strncat example */#include #include 

int main (){  char str1[20];  char str2[20];  strcpy (str1,"To be ");  strcpy (str2,"or not to be");  strncat (str1, str2, 6);  puts (str1);  return 0;}

Output:

To be or not


jnanabhumiap.in 说:
Jan 05, 2024 01:47:52 PM

JNANABHUMI AP offers the most recent information on education. The primary idea or goal of this website has been to offer comprehensive resources with information on any subject that can be accessed online. To make sure that every reader finds out what they should know about the subject they are interested in and jnanabhumiap.in links to our content.Jnanabhumi AP is a startup founded by enthusiastic bloggers and webmasters who are driven to produce interesting, factual, and well-written content. We are similar to an online community where you can find a variety of resources, information, and topics about newsworthy events or daily occurrences.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter