-

Functions HI-TECH C STRCAT

From HI-TECH C for CP/M Fan WIKI(EN)
Revision as of 00:02, 1 August 2017 by Kumokosi (talk | contribs) (Created page with "<strong>STRCAT, STRCMP, STRCPY, STRLEN et. al.</strong> ==SYNOPSIS== #include <string.h> char * strcat(char * s1, char * s2); int strcmp(char * s1, char * s2); char...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

STRCAT, STRCMP, STRCPY, STRLEN et. al.

SYNOPSIS

#include  <string.h>

char *    strcat(char * s1, char * s2);
int strcmp(char * s1, char * s2);
char *    strcpy(char * s1, char * s2);
int strlen(char * s);
char *    strncat(char * s1, char * s2, size_t n);
int strncmp(char * s1, char * s2, size_t n);
char *    strncpy(char * s1, char * s2, size_t n);


DESCRIPTION

These functions provide operations on null-terminated strings. Strcat() appends the string s2 to the end of the string s1. The string at s1 will be null terminated. Needless to say the buffer at s1 must be big enough. Strcmp() compares the two strings and returns a number greater than 0, 0 or a number less than 0 according to whether s1 is greater than, equal to or less than s2. The comparision is via the ascii collating order, with the first character the most significant. Strcpy() copies s2 into the buffer at s1, null terminating it. Strlen() returns the length of s1, not including the terminating null. Strncat(), strncmp() and strncpy() will catenate, compare and copy s2 and s1 in the same manner as their similarly named counterparts above, but involving at most n characters. For strncpy(), the resulting string may not be null terminated.