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

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

Example Files:<br />

Also See:<br />

result is a float.<br />

returns the converted value in result, if any. If no conversion could be<br />

performed, zero is returned.<br />

The strtod function converts the initial portion of the string pointed to by nptr to<br />

a float representation. The part of the string after conversion is stored in the<br />

object pointed to endptr, provided that endptr is not a null pointer. If nptr is<br />

empty or does not have the expected form, no conversion is performed and<br />

the value of nptr is stored in the object pointed to by endptr, provided endptr is<br />

not a null pointer.<br />

All devices.<br />

#INCLUDE <br />

float result;<br />

char str[12]="123.45hello";<br />

char *ptr;<br />

result=strtod(str,&ptr);<br />

//result is 123.45 and ptr is "hello"<br />

None<br />

strtol(), strtoul()<br />

strtok( )<br />

Syntax: ptr = strtok(s1, s2)<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"). s1 may be<br />

0 to indicate a continue operation.<br />

Returns: ptr points to a character in s1 or is 0<br />

Function:<br />

Finds next token in s1 delimited by a character from separator string s2 (which<br />

can be different from call to call), and returns pointer to it.<br />

First call starts at beginning of s1 searching for the first character NOT<br />

contained in s2 and returns null if there is none are found.<br />

If none are found, it is the start of first token (return value). Function then<br />

searches from there for a character contained in s2.<br />

If none are found, current token extends to the end of s1, and subsequent<br />

321

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

Saved successfully!

Ooh no, something went wrong!