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.

Built-in Functions<br />

n is a count of the maximum number of character to operate on.<br />

c is a 8 bit character<br />

m1 and m2 are pointers to memory.<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

Example Files:<br />

Also See:<br />

ptr is a copy of the s1 pointer<br />

iresult is an 8 bit int<br />

result is -1 (less than), 0 (equal) or 1 (greater than)<br />

res is an integer.<br />

Functions are identified above.<br />

All devices.<br />

#include <br />

char string1[10], string2[10];<br />

strcpy(string1,"hi ");<br />

strcpy(string2,"there");<br />

strcat(string1,string2);<br />

printf("Length is %u\r\n", strlen(string1));<br />

// Will print 8<br />

ex_str.c<br />

strcpy(), strtok()<br />

memcpy( ) memmove( )<br />

Syntax: memcpy (destination, source, n)<br />

memmove(destination, source, n)<br />

Parameters:<br />

Returns:<br />

Function:<br />

destination is a pointer to the destination memory.<br />

source is a pointer to the source memory,.<br />

n is the number of bytes to transfer<br />

undefined<br />

Copies n bytes from source to destination in RAM. Be aware that array names<br />

are pointers where other variable names and structure names are not (and<br />

therefore need a & before them).<br />

Memmove performs a safe copy (overlapping objects doesn't cause a<br />

problem). Copying takes place as if the n characters from the source are first<br />

221

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

Saved successfully!

Ooh no, something went wrong!