lecture8-feb5 - Announcements Lecture 8 Assignment 2...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Announcements Lecture 8 • Assignment 2 – Q&A; due Thursday • Topics for today – Character data type and operations – Type conversions within expressions – type conversions in assignment – explicit casting – typedef and sizeof operators – Start 1D arrays ?? (Chapter 8) Char data references • Different computers may have different character sets. We will use ASCII standard • Ascii character set – see book Appendix E or http://www.ascii.cl/ • Example char ch1 = ‘A’, ch2 = ‘B’; If (ch1 < ch2) { /* do something */ ; } • Library functions for char type data – see ch. 23.5, pgs 612-615 – Character classification functions – Character case conversion functions • Look at Chapter 23.1-23.4 for library support functions for all built-in numeric data types character ‘computations’ Mixed with numerics: char ch; int i; i = ‘a’; /* i is now 97 */ ch = 65; /* ch is now ‘A’ */ ch = ch + 1; /* ch is now ‘B’ */ ch++; /* ch is now ‘C’ */ Problems Decreases Portability Assumes knowledge of char set Compiler will not catch certain errors They can be signed or not: signed char sch; /*-128 to 127 */ unsigned char uch; /*0 to 255*/ Std C doesn’t specify which is default For 7 bit ASCII, it doesn’t matter Used in selection and looping: {ch = ch - ‘a’ + ‘A’;} ------------------------------- for (ch = ‘A’; ch <= ‘Z’; ch++) { printf(" %c \n", ch); } C treats characters as small integer values in computations Escape Sequences • Recall that an escape is a \ followed by another character – These have a special meaning for IO operations • Escape sequences represent single characters: \a \b \f \n \r \t \v \\ \? \’ \” • Numeric (Hex) Escapes too \xFF (x lower case, hex characters upper or lower)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/15/2010 for the course EE 16005 taught by Professor Krasner during the Spring '10 term at University of Texas at Austin.

Page1 / 3

lecture8-feb5 - Announcements Lecture 8 Assignment 2...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online