Syntax, Example, Strncat( ) function – Echelon Neuron C User Manual
Page 160: Strncmp( ) function
140
Functions
Syntax
#include
unsigned long strlen (const char *
s
);
Example
#include
void f(void)
{
unsigned long length;
length = strlen("Hello, world!");
}
strncat( )
Function
The strncat( ) function appends a copy of the first
len
characters from the string
src
to the end of the string
dest
, and then adds a NUL ('\0') character, resulting
in concatenated strings (thus the name strncat, from string concatenate). If the
src
string is shorter than
len
, no characters are copied past the NUL character.
The function returns a pointer to the string
dest
. See also strcat( ), strchr( ),
strcmp( ), strcpy( ), strlen( ), strncmp( ), strncpy( ), and strrchr( ).
This function cannot be used to copy overlapping areas of memory, or to write
into EEPROM memory or network variables.
Syntax
#include
char *strncat (char *
dest
, char *
src
, unsigned long
len
);
Example
#include
void f(void)
{
char
buf[40]
strncpy(buf, "Hello Beautiful", 16);
strncat(buf, "World News Tonight", 5);
// buf now contains "Hello Beautiful World"
}
strncmp( )
Function
The strncmp( ) function compares the contents of the
s1
and
s2
strings, up to the
NUL ('\0') terminator character in the shorter string, or until
len
characters have
been compared, whichever occurs first. The function performs a case-sensitive
comparison. If the strings match identically, 0 is returned.