17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Examples:<br />

Example Files:<br />

Also See:<br />

int * iptr;<br />

iptr=malloc(10);<br />

// iptr will point to a block of memory of 10 bytes.<br />

None<br />

realloc(), free(), calloc()<br />

STANDARD STRING FUNCTIONS( ) memchr( ) memcmp( )<br />

strcat( ) strchr( ) strcmp( ) strcoll( ) strcspn( ) strerror( )<br />

stricmp( ) strlen( ) strlwr( ) strncat( ) strncmp( ) strncpy( )<br />

strpbrk( ) strrchr( ) strspn( ) strstr( ) strxfrm( )<br />

Syntax:<br />

ptr=strcat (s1, s2)<br />

ptr=strchr (s1, c)<br />

ptr=strrchr (s1, c)<br />

cresult=strcmp (s1, s2)<br />

iresult=strncmp (s1, s2, n)<br />

iresult=stricmp (s1, s2)<br />

ptr=strncpy (s1, s2, n)<br />

iresult=strcspn (s1, s2)<br />

iresult=strspn (s1, s2)<br />

iresult=strlen (s1)<br />

ptr=strlwr (s1)<br />

ptr=strpbrk (s1, s2)<br />

ptr=strstr (s1, s2)<br />

ptr=strncat(s1,s2)<br />

iresult=strcoll(s1,s2)<br />

res=strxfrm(s1,s2,n)<br />

iresult=memcmp(m1,m2,n)<br />

ptr=memchr(m1,c,n)<br />

ptr=strerror(errnum)<br />

Concatenate s2 onto s1<br />

Find c in s1 and return &s1[i]<br />

Same but search in reverse<br />

Compare s1 to s2<br />

Compare s1 to s2 (n bytes)<br />

Compare and ignore case<br />

Copy up to n characters s2->s1<br />

Count of initial chars in s1 not in s2<br />

Count of initial chars in s1 also in s2<br />

Number of characters in s1<br />

Convert string to lower case<br />

Search s1 for first char also in s2<br />

Search for s2 in s1<br />

Concatenates up to n bytes of s2 onto<br />

s1<br />

Compares s1 to s2, both interpreted as<br />

appropriate to the current locale.<br />

Transforms maximum of n characters<br />

of s2 and places them in s1, such that<br />

strcmp(s1,s2) will give the same result<br />

as strcoll(s1,s2)<br />

Compare m1 to m2 (n bytes)<br />

Find c in first n characters of m1 and<br />

return &m1[i]<br />

Maps the error number in errnum to an<br />

error message string. The parameters<br />

'errnum' is an unsigned 8 bit int.<br />

Returns a pointer to the string.<br />

Parameters:<br />

s1 and s2 are pointers to an array of characters (or the name of an<br />

array). Note that s1 and s2 MAY NOT BE A CONSTANT (like "hi").<br />

220

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!