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 />

Parameters:<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

string is an array of characters.<br />

cstring is a constant string or an array of characters null terminated.<br />

Values are a list of variables separated by commas. Note that format specifies do<br />

not work in ram band strings.<br />

Bytes is the number of bytes written to string.<br />

This function operates like printf() except that the output is placed into the specified<br />

string. The output string will be terminated with a null. No checking is done to ensure<br />

the string is large enough for the data. See printf() for details on formatting.<br />

All devices.<br />

Nothing<br />

char mystring[20];<br />

long mylong;<br />

mylong=1234;<br />

sprintf(mystring,"",mylong);<br />

// mystring now has:<br />

// < 1 2 3 4 > \0<br />

Example<br />

Files:<br />

Also See:<br />

None<br />

printf()<br />

sqrt( )<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

result = sqrt (value)<br />

value is a float<br />

A float<br />

Computes the non-negative square root of the float value x. If the argument is<br />

negative, the behavior is undefined.<br />

Note on error handling:<br />

If "errno.h" is included then the domain and range errors are stored in the<br />

errno variable. The user can check the errno to see if an error has occurred<br />

and print the error using the perror function.<br />

Domain error occurs in the following cases:<br />

sqrt: when the argument is negative<br />

Availability:<br />

All devices.<br />

319

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

Saved successfully!

Ooh no, something went wrong!