This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.

Slides:



Advertisements
Similar presentations
Character Arrays (Single-Dimensional Arrays) A char data type is needed to hold a single character. To store a string we have to use a single-dimensional.
Advertisements

C Characters & Strings Character Review Character Handling Library Initialization String Conversion Functions String Handling Library Standard Input/Output.
Ch 8. Characters and Strings Timothy Budd 2 Characters and Literals Strings Char in C++ is normally an 8-bit quantity, whereas in Java it is a 16-bit.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
Programming Character I/O. COMP102 Prog. Fundamentals I: Character I/O/ Slide 2 More on char Type l Constant Declaration: const char star = '*'; l Variable.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
Programming C/C++ on Eclipe Trình bày : Ths HungNM C/C++ Training.
Wednesday, 10/23/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 10/23/02  QUESTIONS??  Today:  Discussion of HW #3  The const modifier for functions.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
Chapter 8 Characters and Strings Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 8 - Characters and Strings Outline 8.1Introduction.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
1 Character Processing How characters can be treated as small integers? How characters are stored and manipulated in a machine? How use is made of certain.
CS161 Introduction to Computer Science Character Data.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
CS Nov 2006 C-strings.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 12 More.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
A function is a subprogram that acts on data and often returns a value. You are already familiar with the one function that every C++ program possesses:
 2007 Pearson Education, Inc. All rights reserved C Characters and Strings.
First Program in C With Output. C Language Keywords.
1 Chapter 10 Characters, Strings, and the string class.
CHAPTER 8 CHARACTER AND STRINGS
 2000 Prentice Hall, Inc. All rights reserved. Chapter 8 - Characters and Strings Outline 8.1Introduction 8.2Fundamentals of Strings and Characters 8.3Character.
February 14, 2005 Characters, Strings and the String Class.
1 Lecture09: Global Variables, File I/O, and Variable-Length Arguments 5/16/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction to C.
CSE 232: C++ Input/Output Manipulation Built-In and Simple User Defined Types in C++ int, long, short, char (signed, integer division) –unsigned versions.
Chapter 10. Characters, Strings and the string class Csc 125 Introduction to C++ Fall 2005.
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
Data Types & I/O Streams Objectives Data Types Understand that integers form the underlying foundation for many data types. Introduce a few frequently.
Copyright © 2012 Pearson Education, Inc. Chapter 10: Characters, C- Strings, and More About the string Class.
Arrays II (Strings). Data types in C Integer : int i; Double: double x; Float: float y; Character: char ch; char cha[10], chb[]={‘h’,’e’,’l’,’l’,’o’};
Copyright © 2012 Pearson Education, Inc. Chapter 10: Characters, C- Strings, and More About the string Class.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10: Characters, Strings, and the string class.
C How to Program, 7/e © by Pearson Education, Inc. All Rights Reserved.
Characters, Strings, And The string Class Chapter 10.
1 Object-Oriented Programming -- Using C++ Andres, Wen-Yuan Liao Department of Computer Science and Engineering De Lin Institute of Technology
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 10: Characters, C- Strings, and More About.
C++ for Engineers and Scientists Second Edition Chapter 7 Completing the Basics.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 10 Characters, Strings, and the string class.
CSC Programming for Science Lecture 8: Character Functions.
Chapter Characters, Strings, and the string class 10.
CTYPE.H Introduction  The ctype header is used for testing and converting characters.  A control character refers to a character that.
Sudeshna Sarkar, IIT Kharagpur 1 I/O in C + Misc Lecture –
Strings, and the string Class. C-Strings C-string: sequence of characters stored in adjacent memory locations and terminated by NULL character The C-string.
C Characters and Strings
C Characters and Strings
Character Processing How characters can be treated as small integers?
Characters, C-Strings, and More About the string Class
I/O in C + Misc Lecture Sudeshna Sarkar, IIT Kharagpur.
Chapter 8 - Characters and Strings
Standard Version of Starting Out with C++, 4th Edition
Decision Making.
10.1 Character Testing.
Character Processing How characters can be treated as small integers?
Standard Version of Starting Out with C++, 4th Edition
C Characters and Strings
Boolean in C++ CSCE 121.
Presentation transcript:

This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed. If you have opened this lesson in PowerPoint, use the PowerPoint menus to view it in slide show mode. If you have opened this lesson in a browser and see a bar similar to that below, click on the Slide Show icon A notice similar to the one below may appear warning that ActiveX or other scripts are disabled. Enable the controls for this website in order to see the animations.

ctype.h Christine S. Wolfe Ohio University Lancaster 2008-Aug-01 This lesson introduces the library functions included in ctype.h: Vocabulary: ctype.h isalnum() isalpha() iscntrl() isdigit() isgraph() islower() isprint() ispunct() isspace() isupper() isxdigit() tolower() toupper()

C Primer Plus®, Third Edition by Stephen Prata. Publisher: Sams Pub Date: September 28, 1998 Print ISBN-10: Table 7.1. ctype.h character-testing functions. NameTrue If Argument Is isalnum()Alphanumeric (alphabetic or numeric) isalpha()Alphabetic iscntrl()A control character, such as Ctrl+B isdigit()A digit isgraph()Any printing character other than a space islower()A lowercase character isprint()A printing character ispunct()A punctuation character (any printing character other than a space or an alphanumeric character) isspace()A whitespace character: space, newline, formfeed, carriage return, vertical tab, horizontal tab, or, possibly, other implementation-defined characters isupper()An uppercase character isxdigit()A hexadecimal-digit character Table 7.2. ctype.h character-mapping functions. NameAction tolower()If the argument is an uppercase character, returns the lowercase version; otherwise, just returns the original argument toupper()If the argument is a lowercase character, returns the uppercase version; otherwise, just returns the original argument The ctype.h header file includes several useful functions. The argument for these functions is a single char.

Before these functions can be used in a program, the ctype.h library must be included. #include int main() { char Response; printf("Please enter your selection: "); fflush(stdin); scanf("\n%c", &Response); if ( toupper(Response) == 'Q') { return 0; } }

isalnum() isalpha() iscntrl() isdigit() isgraph() islower() isprint() ispunct() isspace() isupper() isxdigit() The ctype functions that begin with "is" are boolean. That means they return either TRUE or FALSE, the logical values.

Given that the user entered 'A' as Response, what is the value of each of these expressions? isalnum(Response) isalpha(Response) iscntrl(Response) isdigit(Response) isgraph(Response) islower(Response) isprint(Response) ispunct(Response) isspace(Response) isupper(Response) isxdigit(Response) Click for answer True False True False True False True Click for answer

Given that the user entered '6' as Response, what is the value of each of these expressions? isalnum(Response) isalpha(Response) iscntrl(Response) isdigit(Response) isgraph(Response) islower(Response) isprint(Response) ispunct(Response) isspace(Response) isupper(Response) isxdigit(Response) Click for answer True False True False True False True Click for answer

tolower() toupper() The ctype functions that begin with "to" return a char value. They do NOT change the value of the argument itself. For example: Letter1 = toupper(Letter2); BEFOREAFTER Letter1Letter2Letter1Letter2 hHh GGG 666 ;;;

The argument for the ctype.h library functions MUST BE A char!!! Given the declarations below, the following statements are syntactically incorrect: int NumIn = 345; char Name[20] = "hal"; char Proper[20]; if (isDigit(NumIn)) Proper = toupper(Name); Please don't look at this slide for too long - I don't to plant these ideas in your head if they weren't already there!!!