100 likes | 222 Views
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.
E N D
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 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() Christine S. Wolfe Ohio University Lancaster 2008-Aug-01
The ctype.h header file includes several useful functions. The argument for these functions is a single char. C Primer Plus®, Third Edition by Stephen Prata. Publisher: Sams Pub Date: September 28, 1998 Print ISBN-10: 1-57169-161-8
Before these functions can be used in a program, the ctype.h library must be included. #include <stdio.h> #include <ctype.h> int main() { char Response; printf("Please enter your selection: "); fflush(stdin); scanf("\n%c", &Response); if ( toupper(Response) == 'Q') { return 0; } }
The ctype functions that begin with "is" are boolean. That means they return either TRUE or FALSE, the logical values. isalnum() isalpha() iscntrl() isdigit() isgraph() islower() isprint() ispunct() isspace() isupper() isxdigit()
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) True Click for answer True Click for answer False Click for answer False Click for answer True Click for answer False Click for answer True Click for answer False Click for answer False Click for answer True Click for answer 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) True Click for answer False Click for answer False Click for answer True Click for answer True Click for answer False Click for answer True Click for answer False Click for answer False Click for answer False Click for answer True Click for answer
The ctype functions that begin with "to" return a char value. tolower() toupper() They do NOT change the value of the argument itself. For example: Letter1 = toupper(Letter2);
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!!!