SlideShare une entreprise Scribd logo
1  sur  49
A First Book of ANSI C Fourth Edition Chapter 9 Character Strings
Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String Fundamentals ,[object Object],[object Object],[object Object],[object Object]
String Input and Output ,[object Object],[object Object],[object Object]
String Input and Output (continued)
String Input and Output (continued) Sample run: Enter a string: This is a test input of a string of characters. The string just entered is: This is a test input of a string of characters.
String Input and Output (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String Input and Output (continued)
String Processing
String Processing (continued)
NOTE: Because the expression  string2[i]  is only 0 at the end of a string and non-0 for every other character, the expression  while (string2[i] != '')  can be replaced by the simpler expression  while (string2[i]) . String Processing (continued)
String Processing (continued)
Be careful: omitting the parentheses causes the entire expression to be equivalent to c = (getchar() != '') String Processing (continued)
String Processing (continued)
Library Functions Note: Attempting to copy a larger string into a smaller string causes the copy to overflow the destination array beginning with the memory area immediately following the last array element.
Library Functions (continued)
Library Functions (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Library Functions (continued)
Library Functions (continued)
Library Functions (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Character Routines
Character Routines (continued)
Conversion Routines
Conversion Routines (continued)
Input Data Validation ,[object Object],[object Object],[object Object],[object Object],[object Object]
Input Data Validation (continued)
Input Data Validation (continued)
Input Data Validation (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Input Data Validation (continued) …
Creating a Personal Library ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Formatting Strings ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
In-Memory String Conversions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Format Strings ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Case Study: Character and Word Counting ,[object Object],[object Object],[object Object],[object Object]
Program Requirement: Character Counting ,[object Object],[object Object],[object Object]
Analyze the Problem ,[object Object],[object Object],[object Object]
Analyze the Problem (continued)
Code the Function ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Test and Debug the Function …
Requirement Specification: Word Counting ,[object Object],[object Object],[object Object]
Analyze the Problem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Code the Function ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Test and Debug the Function …
Test and Debug the Function (continued) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Common Programming Errors ,[object Object],[object Object],[object Object],[object Object]
Common Compiler Errors
Common Compiler Errors (continued)
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object]
Summary (continued) ,[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiSowmyaJyothi3
 
Ch3 Formatted Input/Output
Ch3 Formatted Input/OutputCh3 Formatted Input/Output
Ch3 Formatted Input/OutputSzeChingChen
 
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHMCLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHMRc Os
 
Ch5 Selection Statements
Ch5 Selection StatementsCh5 Selection Statements
Ch5 Selection StatementsSzeChingChen
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiSowmya Jyothi
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CSowmya Jyothi
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTanzeela_Hussain
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 SlidesRakesh Roshan
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cSowmya Jyothi
 
Control structures functions and modules in python programming
Control structures functions and modules in python programmingControl structures functions and modules in python programming
Control structures functions and modules in python programmingSrinivas Narasegouda
 

Tendances (17)

Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
 
Ch3 Formatted Input/Output
Ch3 Formatted Input/OutputCh3 Formatted Input/Output
Ch3 Formatted Input/Output
 
Ch7 Basic Types
Ch7 Basic TypesCh7 Basic Types
Ch7 Basic Types
 
FUNDAMENTAL OF C
FUNDAMENTAL OF CFUNDAMENTAL OF C
FUNDAMENTAL OF C
 
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHMCLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
CLASS VIII COMPUTERS FLOW CHART AND ALGORITHM
 
Ch5 Selection Statements
Ch5 Selection StatementsCh5 Selection Statements
Ch5 Selection Statements
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya Jyothi
 
Python Objects
Python ObjectsPython Objects
Python Objects
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statements
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
 
Looping
LoopingLooping
Looping
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 Slides
 
Ch8 Arrays
Ch8 ArraysCh8 Arrays
Ch8 Arrays
 
Function
FunctionFunction
Function
 
Unit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in cUnit ii chapter 1 operator and expressions in c
Unit ii chapter 1 operator and expressions in c
 
Control structures functions and modules in python programming
Control structures functions and modules in python programmingControl structures functions and modules in python programming
Control structures functions and modules in python programming
 

En vedette

Managing Diversity. 441
Managing Diversity. 441Managing Diversity. 441
Managing Diversity. 441guestca2b8d0
 
Ch org culrure,envioronmnet and constraints
Ch org culrure,envioronmnet and constraintsCh org culrure,envioronmnet and constraints
Ch org culrure,envioronmnet and constraintsMisbahUllah312
 
Session 6 merchandising1
Session 6 merchandising1Session 6 merchandising1
Session 6 merchandising1Arriz San Juan
 
Managing Diversity
Managing DiversityManaging Diversity
Managing Diversityhumaapkeliye
 
Ch 7 foundations of planning
Ch 7 foundations of planningCh 7 foundations of planning
Ch 7 foundations of planningNardin A
 
Ch 18 managing operations
Ch 18 managing operationsCh 18 managing operations
Ch 18 managing operationsNardin A
 
Chapter 10ii 2010
Chapter 10ii 2010Chapter 10ii 2010
Chapter 10ii 2010Nardin A
 
Ch 17 introduction to controlling
Ch 17 introduction to controllingCh 17 introduction to controlling
Ch 17 introduction to controllingNardin A
 
Ch 6 managers as decision makers
Ch 6 managers as decision makersCh 6 managers as decision makers
Ch 6 managers as decision makersNardin A
 
Pengantar manajemen
Pengantar manajemenPengantar manajemen
Pengantar manajemenDissa MeLina
 
Ninth edition stephen p. robbins power point presentation by mukhtar untirta ...
Ninth edition stephen p. robbins power point presentation by mukhtar untirta ...Ninth edition stephen p. robbins power point presentation by mukhtar untirta ...
Ninth edition stephen p. robbins power point presentation by mukhtar untirta ...Bobby D'Arch
 
Chapter 1 Introduction
Chapter 1 IntroductionChapter 1 Introduction
Chapter 1 IntroductionNardin A
 

En vedette (12)

Managing Diversity. 441
Managing Diversity. 441Managing Diversity. 441
Managing Diversity. 441
 
Ch org culrure,envioronmnet and constraints
Ch org culrure,envioronmnet and constraintsCh org culrure,envioronmnet and constraints
Ch org culrure,envioronmnet and constraints
 
Session 6 merchandising1
Session 6 merchandising1Session 6 merchandising1
Session 6 merchandising1
 
Managing Diversity
Managing DiversityManaging Diversity
Managing Diversity
 
Ch 7 foundations of planning
Ch 7 foundations of planningCh 7 foundations of planning
Ch 7 foundations of planning
 
Ch 18 managing operations
Ch 18 managing operationsCh 18 managing operations
Ch 18 managing operations
 
Chapter 10ii 2010
Chapter 10ii 2010Chapter 10ii 2010
Chapter 10ii 2010
 
Ch 17 introduction to controlling
Ch 17 introduction to controllingCh 17 introduction to controlling
Ch 17 introduction to controlling
 
Ch 6 managers as decision makers
Ch 6 managers as decision makersCh 6 managers as decision makers
Ch 6 managers as decision makers
 
Pengantar manajemen
Pengantar manajemenPengantar manajemen
Pengantar manajemen
 
Ninth edition stephen p. robbins power point presentation by mukhtar untirta ...
Ninth edition stephen p. robbins power point presentation by mukhtar untirta ...Ninth edition stephen p. robbins power point presentation by mukhtar untirta ...
Ninth edition stephen p. robbins power point presentation by mukhtar untirta ...
 
Chapter 1 Introduction
Chapter 1 IntroductionChapter 1 Introduction
Chapter 1 Introduction
 

Similaire à Ch09

Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programmingAppili Vamsi Krishna
 
3 character strings and formatted input output
3  character strings and formatted input output3  character strings and formatted input output
3 character strings and formatted input outputMomenMostafa
 
0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdfssusere19c741
 
stringsinpython-181122100212.pdf
stringsinpython-181122100212.pdfstringsinpython-181122100212.pdf
stringsinpython-181122100212.pdfpaijitk
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Languagezone
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoobirbal
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming LanguageRaghavan Mohan
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de JavascriptBernard Loire
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSowmyaJyothi3
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiSowmya Jyothi
 
STRINGS_IN_PYTHON 9-12 (1).pptx
STRINGS_IN_PYTHON 9-12 (1).pptxSTRINGS_IN_PYTHON 9-12 (1).pptx
STRINGS_IN_PYTHON 9-12 (1).pptxTinku91
 

Similaire à Ch09 (20)

Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
3 character strings and formatted input output
3  character strings and formatted input output3  character strings and formatted input output
3 character strings and formatted input output
 
0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf
 
stringsinpython-181122100212.pdf
stringsinpython-181122100212.pdfstringsinpython-181122100212.pdf
stringsinpython-181122100212.pdf
 
String notes
String notesString notes
String notes
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Javascript
JavascriptJavascript
Javascript
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothi
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
 
Lecture 05 2017
Lecture 05 2017Lecture 05 2017
Lecture 05 2017
 
Javascript
JavascriptJavascript
Javascript
 
STRINGS_IN_PYTHON 9-12 (1).pptx
STRINGS_IN_PYTHON 9-12 (1).pptxSTRINGS_IN_PYTHON 9-12 (1).pptx
STRINGS_IN_PYTHON 9-12 (1).pptx
 
COm1407: Character & Strings
COm1407: Character & StringsCOm1407: Character & Strings
COm1407: Character & Strings
 
string in C
string in Cstring in C
string in C
 

Plus de Arriz San Juan

Plus de Arriz San Juan (12)

9. logic gates._rr
9. logic gates._rr9. logic gates._rr
9. logic gates._rr
 
7. kirchhoff s_rules
7. kirchhoff s_rules7. kirchhoff s_rules
7. kirchhoff s_rules
 
9. transistors.rr
9. transistors.rr9. transistors.rr
9. transistors.rr
 
12 exception handling
12 exception handling12 exception handling
12 exception handling
 
12 exception handling
12 exception handling12 exception handling
12 exception handling
 
Chap 17 controlling
Chap 17 controllingChap 17 controlling
Chap 17 controlling
 
11 advance inheritance_concepts
11 advance inheritance_concepts11 advance inheritance_concepts
11 advance inheritance_concepts
 
9. transistors.rr
9. transistors.rr9. transistors.rr
9. transistors.rr
 
8. semiconductors.rr
8. semiconductors.rr8. semiconductors.rr
8. semiconductors.rr
 
7. kirchhoff s_rules
7. kirchhoff s_rules7. kirchhoff s_rules
7. kirchhoff s_rules
 
Ch13
Ch13Ch13
Ch13
 
Ch07
Ch07Ch07
Ch07
 

Ch09