Microprocessors: From Assembly Language to C Using thePIC18Fxx2

This appendix contains a few brief notes on the C programming language based on questions asked by students when performing the laboratory exercises in Appendix E, "Suggested Laboratory Exercises." This book only covers a subset of the C language and the coverage is intended to be adequate for a student already conversant in some other high-level language, either object oriented (e.g., C++, Java) or procedural (e.g., BASIC, Pascal).
The formatted IO statements printf() and scanf() can be confusing if you are new to C. This appendix only covers the formatted IO features used in this book's examples; please refer to a C textbook if you require a more complete description. The printf() statement is used for formatted ASCII output; within the PICC-18 C compiler environment the printf() library function calls the putch() function to output each ASCII byte. Chapter 9, "Asynchronous Serial IO," gives a putch() function that outputs the byte to the PIC18Fxx2 serial port. The parameters to the printf() function are a format string and an argument list. The format string can contain a mixture of normal characters and conversion specifications; a conversion specification determines how an argument value is converted to an ASCII format. Conversion specifications begin with a "%" character; two "%" characters in a row are needed if a "%" is desired in the final output string. Figure D.1a gives some examples of printf()