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

Availability:<br />

Requires:<br />

Examples:<br />

Example Files:<br />

Also See:<br />

All devices.<br />

#INCLUDE <br />

signed long result;<br />

char str[9]="123hello";<br />

char *ptr;<br />

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

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

None<br />

strtod(), strtoul()<br />

strtoul( )<br />

Syntax:<br />

result=strtoul(nptr,endptr, base)<br />

Parameters: nptr and endptr are strings pointers and base is an integer 2-36.<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

result is an unsigned long int.<br />

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

performed, zero is returned.<br />

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

to a long int representation in some radix determined by the value of base.<br />

The part of the string after conversion is stored in the object pointed to endptr,<br />

provided that endptr is not a null pointer. If nptr is empty or does not have the<br />

expected form, no conversion is performed and the value of nptr is stored in<br />

the object pointed to by endptr, provided endptr is not a null pointer.<br />

All devices.<br />

STDLIB.H must be included<br />

long result;<br />

char str[9]="123hello";<br />

char *ptr;<br />

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

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

Example Files:<br />

Also See:<br />

None<br />

strtol(), strtod()<br />

323

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

Saved successfully!

Ooh no, something went wrong!