Strcpy( ) function, Syntax, Example – Echelon Neuron C User Manual
Page 159: Strlen( ) function
Neuron C Reference Guide
139
{
int
val;
char s1[20], s2[20];
val = strcmp(s1, s2);
if (!val) {
// Strings are equal
} else if (val < 0) {
// String s1 is less than s2
} else {
// String s1 is greater than s2
}
}
strcpy( )
Function
The strcpy( ) function copies the string pointed to by the parameter
src
into the
string buffer pointed to by the parameter
dest
. The copy ends implicitly, when
the terminating NUL ('\0') character is copied—no string length information is
available to the function. There is no attempt to ensure that the string can
actually fit in the available memory. That task is left up to the programmer. See
also strcat( ), strchr( ), strcmp( ), strlen( ), strncat( ), strncmp( ), strncpy( ), and
strrchr( ).
This function cannot be used to copy overlapping areas of memory, or to write
into EEPROM memory. Use of the compiler directive #pragma
relaxed_casting_on is needed to copy to a network variable, and doing so does not
automatically propagate the network variable update (see the propagate( )
function).
Syntax
#include
char *strcpy (char *
dest
, const char *
src
);
Example
#include
void f(void)
{
char s1[20], s2[20];
strcpy(s1, "Hello World");
strcpy(s2,
s1);
}
strlen( )
Function
The strlen( ) function returns the length of the string
s
, not including the
terminating NUL ('\0') character. See also strcat( ), strchr( ), strcmp( ), strcpy( ),
strncat( ), strncmp( ), strncpy( ), and strrchr( ).