17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Built-in Functions<br />

Example<br />

Files:<br />

Also See:<br />

ex_admm.c<br />

read_adc(), setup_adc(), setup_adc_ports(), ADC Overview<br />

scanf( )<br />

printf( )<br />

Syntax:<br />

scanf(cstring);<br />

scanf(cstring, values...)<br />

fscanf(stream, cstring, values...)<br />

Parameters: cstring is a constant string.<br />

values is a list of variables separated by commas.<br />

stream is a stream identifier.<br />

Returns:<br />

Function:<br />

0 if a failure occurred, otherwise it returns the number of conversion specifiers<br />

that were read in, plus the number of constant strings read in.<br />

Reads in a string of characters from the standard RS-232 pins and formats the<br />

string according to the format specifiers. The format specifier character (%)<br />

used within the string indicates that a conversion specification is to be done and<br />

the value is to be saved into the corresponding argument variable. A %% will<br />

input a single %. Formatting rules for the format specifier as follows:<br />

If fscanf() is used, then the specified stream is used, where scanf() defaults to<br />

STDIN (the last USE RS232).<br />

Format:<br />

The format takes the generic form %nt. n is an option and may be 1-99<br />

specifying the field width, the number of characters to be inputted. t is the type<br />

and maybe one of the following:<br />

c<br />

s<br />

Matches a sequence of characters of the number specified by the<br />

field width (1 if no field width is specified). The corresponding<br />

argument shall be a pointer to the initial character of an array long<br />

enough to accept the sequence.<br />

Matches a sequence of non-white space characters. The<br />

corresponding argument shall be a pointer to the initial character<br />

of an array long enough to accept the sequence and a<br />

terminating null character, which will be added automatically.<br />

265

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

Saved successfully!

Ooh no, something went wrong!