SlideShare a Scribd company logo
Team Emertxe
Strings and Storage
Classes
Assignment 7
Assignment 7
Assignment 7
WAP to implement strtok function
Assignment 7
WAP to implement strtok function
Input:
Assignment 7
WAP to implement strtok function
Input: Read two Strings.
Assignment 7
WAP to implement strtok function
Input: Read two Strings.
Output:
Assignment 7
WAP to implement strtok function
Input: Read two Strings.
Output: Print tokens from string.
Assignment 7
What is strtok() function?
Assignment 7
What is strtok() function?
 The strtok() function breaks a string into a sequence of zero or
more nonempty tokens.
 On the first call to strtok(), the string to be parsed should be
specified in str. In each subsequent call that should parse the
same string, str must be NULL.
Assignment 7
What is strtok() function?
 The strtok() function breaks a string into a sequence of zero or
more nonempty tokens.
 On the first call to strtok(), the string to be parsed should be
specified in str. In each subsequent call that should parse the
same string, str must be NULL.
Prototype: char *strtok(char *str, const char *delim);
Assignment 7
Let’s understand how strtok() works:
Assignment 7
Let’s understand how strtok() works:
Assignment 7
Let’s understand how strtok() works:
What will be printed?
Assignment 7
Let’s understand how strtok() works:
“Are” will be printed
O/p of the program:
Are
Assignment 7
Let’s understand how strtok() works:
What will be printed?
Assignment 7
Let’s understand how strtok() works:
“Are” will be printed
“Are” will be printed
O/p of the program:
Are
Are
Assignment 7
Let’s understand how strtok() works:
But, the next token
should be printed is
“you”
“Are” will be printed
“Are” will be printed
O/p of the program:
Are
Are
Assignment 7
Let’s understand how strtok() works:
What will be printed?
What will be printed?
Assignment 7
Let’s understand how strtok() works:
“you” will be printed
“Are” will be printed
O/p of the program:
Are
you
Assignment 7
Let’s understand how strtok() works:
O/p of the program:
Are
you
How will you print the
remaining tokens?
Assignment 7
Let’s understand how strtok() works:
What is the output?
Assignment 7
Let’s understand how strtok() works:
O/p of the program:
Are
You
okay
Assignment 7
How to implement your own strtok() function?
Assignment 7
How to implement your own strtok() function?
 Input: str = “Are;you:okay”
delim = “;:”
A r e ; y o u : o k a y 0
; : 0
str
delim String containing delimiters,
these delimiters has to be
matched with each and every
character of str
Assignment 7
A r e ; y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Assignment 7
A r e ; y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Assignment 7
A r e ; y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Assignment 7
A r e ; y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Assignment 7
A r e ; y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Assignment 7
A r e ; y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Assignment 7
A r e ; y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos Here at pos 3, delimiter is
encountered, so overwrite that
byte with ‘0’
Assignment 7
A r e 0 y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos Return the address using str +
start_index and do pos++
Assignment 7
A r e 0 y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos Return the address using str +
start_index and do pos++
Output:
Are
Assignment 7
A r e 0 y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
Assignment 7
A r e 0 y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
Assignment 7
A r e 0 y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
Assignment 7
A r e 0 y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
Assignment 7
A r e 0 y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
Assignment 7
A r e 0 y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
Assignment 7
A r e 0 y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
Assignment 7
A r e 0 y o u : o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
Here at pos 7, delimiter is
encountered, so overwrite that
byte with ‘0’
Assignment 7
A r e 0 y o u 0 o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
You
Return the address using str +
start_index and do pos++
Assignment 7
A r e 0 y o u 0 o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
You
Assignment 7
A r e 0 y o u 0 o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
You
Assignment 7
A r e 0 y o u 0 o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
You
Assignment 7
A r e 0 y o u 0 o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
You
Assignment 7
A r e 0 y o u 0 o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
You
Assignment 7
A r e 0 y o u 0 o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
You
Assignment 7
A r e 0 y o u 0 o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
You
Assignment 7
A r e 0 y o u 0 o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
You
Assignment 7
A r e 0 y o u 0 o k a y 0
; : 0
str
delim
0 1 2 3 4 5 6 7 8 9 10 11 12
start_index
 Input: str = “Are;you:okay”
delim = “;:”
pos
Output:
Are
You
okay
Return the address using str +
start_index
Assignment 7
Sample execution:-
Assignment 7
Sample execution:-
Assignment 7
Sample execution:-
Assignment 7
Pre-requisites:-
Assignment 7
Pre-requisites:-
⮚Strings
Assignment 7
Pre-requisites:-
⮚Strings
⮚Storage Classes
Assignment 7
Pre-requisites:-
⮚Strings
⮚Storage Classes
⮚Pointers
Assignment 7
Pre-requisites:-
⮚Strings
⮚Storage Classes
⮚Pointers
Objective:-
Assignment 7
Pre-requisites:-
⮚Strings
⮚Storage Classes
⮚Pointers
Objective:-
To understand the concept of String functions.
Team Emertxe
Thank you

More Related Content

Similar to 07_strtok.pdf

05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
Kelly Swanson
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
rhshriva
 
JSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael GreifenederJSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael Greifeneder
Christoph Pickl
 
Advanced perl finer points ,pack&unpack,eval,files
Advanced perl   finer points ,pack&unpack,eval,filesAdvanced perl   finer points ,pack&unpack,eval,files
Advanced perl finer points ,pack&unpack,eval,files
Shankar D
 
14 strings
14 strings14 strings
14 strings
Rohit Shrivastava
 
Knit One, Compute One - YOW! Night Perth
Knit One, Compute One - YOW! Night PerthKnit One, Compute One - YOW! Night Perth
Knit One, Compute One - YOW! Night Perth
Kristine Howard
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parser
kamaelian
 
Strings and Characters
Strings and CharactersStrings and Characters
Strings and Characters
Andy Juan Sarango Veliz
 
07_triangle_pattern.pdf
07_triangle_pattern.pdf07_triangle_pattern.pdf
C Programming Strings.docx
C Programming Strings.docxC Programming Strings.docx
C Programming Strings.docx
8759000398
 
How to Vim - for beginners
How to Vim - for beginnersHow to Vim - for beginners
How to Vim - for beginners
Marcin Rogacki
 
L-13 part2-string handling.pptx
L-13 part2-string handling.pptxL-13 part2-string handling.pptx
L-13 part2-string handling.pptx
UditGupta176477
 
09_isalnum.pdf
09_isalnum.pdf09_isalnum.pdf
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.
Workhorse Computing
 
Brief instruction on backprop
Brief instruction on backpropBrief instruction on backprop
Brief instruction on backprop
YasutoTamura1
 
Zend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryZend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j query
Tricode (part of Dept)
 
13 Strings and Text Processing
13 Strings and Text Processing13 Strings and Text Processing
13 Strings and Text Processing
Intro C# Book
 
CS.3.Arrays.pdf
CS.3.Arrays.pdfCS.3.Arrays.pdf
CS.3.Arrays.pdf
YasirAli74993
 
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Andrea Telatin
 
OSS BarCamp Mumbai - JSON Presentation and Demo
OSS BarCamp Mumbai - JSON Presentation and DemoOSS BarCamp Mumbai - JSON Presentation and Demo
OSS BarCamp Mumbai - JSON Presentation and Demo
Ketan Khairnar
 

Similar to 07_strtok.pdf (20)

05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
JSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael GreifenederJSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael Greifeneder
 
Advanced perl finer points ,pack&unpack,eval,files
Advanced perl   finer points ,pack&unpack,eval,filesAdvanced perl   finer points ,pack&unpack,eval,files
Advanced perl finer points ,pack&unpack,eval,files
 
14 strings
14 strings14 strings
14 strings
 
Knit One, Compute One - YOW! Night Perth
Knit One, Compute One - YOW! Night PerthKnit One, Compute One - YOW! Night Perth
Knit One, Compute One - YOW! Night Perth
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parser
 
Strings and Characters
Strings and CharactersStrings and Characters
Strings and Characters
 
07_triangle_pattern.pdf
07_triangle_pattern.pdf07_triangle_pattern.pdf
07_triangle_pattern.pdf
 
C Programming Strings.docx
C Programming Strings.docxC Programming Strings.docx
C Programming Strings.docx
 
How to Vim - for beginners
How to Vim - for beginnersHow to Vim - for beginners
How to Vim - for beginners
 
L-13 part2-string handling.pptx
L-13 part2-string handling.pptxL-13 part2-string handling.pptx
L-13 part2-string handling.pptx
 
09_isalnum.pdf
09_isalnum.pdf09_isalnum.pdf
09_isalnum.pdf
 
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.
 
Brief instruction on backprop
Brief instruction on backpropBrief instruction on backprop
Brief instruction on backprop
 
Zend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryZend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j query
 
13 Strings and Text Processing
13 Strings and Text Processing13 Strings and Text Processing
13 Strings and Text Processing
 
CS.3.Arrays.pdf
CS.3.Arrays.pdfCS.3.Arrays.pdf
CS.3.Arrays.pdf
 
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
Bioinformatica: Leggere file con Perl, e introduzione alle espressioni regola...
 
OSS BarCamp Mumbai - JSON Presentation and Demo
OSS BarCamp Mumbai - JSON Presentation and DemoOSS BarCamp Mumbai - JSON Presentation and Demo
OSS BarCamp Mumbai - JSON Presentation and Demo
 

More from Emertxe Information Technologies Pvt Ltd

Career Transition (1).pdf
Career Transition (1).pdfCareer Transition (1).pdf
Career Transition (1).pdf
Emertxe Information Technologies Pvt Ltd
 
10_isxdigit.pdf
10_isxdigit.pdf10_isxdigit.pdf
01_student_record.pdf
01_student_record.pdf01_student_record.pdf
02_swap.pdf
02_swap.pdf02_swap.pdf
01_sizeof.pdf
01_sizeof.pdf01_sizeof.pdf
07_product_matrix.pdf
07_product_matrix.pdf07_product_matrix.pdf
06_sort_names.pdf
06_sort_names.pdf06_sort_names.pdf
05_fragments.pdf
05_fragments.pdf05_fragments.pdf
04_magic_square.pdf
04_magic_square.pdf04_magic_square.pdf
03_endianess.pdf
03_endianess.pdf03_endianess.pdf
02_variance.pdf
02_variance.pdf02_variance.pdf
01_memory_manager.pdf
01_memory_manager.pdf01_memory_manager.pdf
09_nrps.pdf
09_nrps.pdf09_nrps.pdf
11_pangram.pdf
11_pangram.pdf11_pangram.pdf
10_combinations.pdf
10_combinations.pdf10_combinations.pdf
08_squeeze.pdf
08_squeeze.pdf08_squeeze.pdf
06_reverserec.pdf
06_reverserec.pdf06_reverserec.pdf
05_reverseiter.pdf
05_reverseiter.pdf05_reverseiter.pdf
04_itoa.pdf
04_itoa.pdf04_itoa.pdf

More from Emertxe Information Technologies Pvt Ltd (20)

premium post (1).pdf
premium post (1).pdfpremium post (1).pdf
premium post (1).pdf
 
Career Transition (1).pdf
Career Transition (1).pdfCareer Transition (1).pdf
Career Transition (1).pdf
 
10_isxdigit.pdf
10_isxdigit.pdf10_isxdigit.pdf
10_isxdigit.pdf
 
01_student_record.pdf
01_student_record.pdf01_student_record.pdf
01_student_record.pdf
 
02_swap.pdf
02_swap.pdf02_swap.pdf
02_swap.pdf
 
01_sizeof.pdf
01_sizeof.pdf01_sizeof.pdf
01_sizeof.pdf
 
07_product_matrix.pdf
07_product_matrix.pdf07_product_matrix.pdf
07_product_matrix.pdf
 
06_sort_names.pdf
06_sort_names.pdf06_sort_names.pdf
06_sort_names.pdf
 
05_fragments.pdf
05_fragments.pdf05_fragments.pdf
05_fragments.pdf
 
04_magic_square.pdf
04_magic_square.pdf04_magic_square.pdf
04_magic_square.pdf
 
03_endianess.pdf
03_endianess.pdf03_endianess.pdf
03_endianess.pdf
 
02_variance.pdf
02_variance.pdf02_variance.pdf
02_variance.pdf
 
01_memory_manager.pdf
01_memory_manager.pdf01_memory_manager.pdf
01_memory_manager.pdf
 
09_nrps.pdf
09_nrps.pdf09_nrps.pdf
09_nrps.pdf
 
11_pangram.pdf
11_pangram.pdf11_pangram.pdf
11_pangram.pdf
 
10_combinations.pdf
10_combinations.pdf10_combinations.pdf
10_combinations.pdf
 
08_squeeze.pdf
08_squeeze.pdf08_squeeze.pdf
08_squeeze.pdf
 
06_reverserec.pdf
06_reverserec.pdf06_reverserec.pdf
06_reverserec.pdf
 
05_reverseiter.pdf
05_reverseiter.pdf05_reverseiter.pdf
05_reverseiter.pdf
 
04_itoa.pdf
04_itoa.pdf04_itoa.pdf
04_itoa.pdf
 

Recently uploaded

Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
NelTorrente
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
christianmathematics
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 

Recently uploaded (20)

Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 

07_strtok.pdf

  • 1. Team Emertxe Strings and Storage Classes
  • 4. Assignment 7 WAP to implement strtok function
  • 5. Assignment 7 WAP to implement strtok function Input:
  • 6. Assignment 7 WAP to implement strtok function Input: Read two Strings.
  • 7. Assignment 7 WAP to implement strtok function Input: Read two Strings. Output:
  • 8. Assignment 7 WAP to implement strtok function Input: Read two Strings. Output: Print tokens from string.
  • 9. Assignment 7 What is strtok() function?
  • 10. Assignment 7 What is strtok() function?  The strtok() function breaks a string into a sequence of zero or more nonempty tokens.  On the first call to strtok(), the string to be parsed should be specified in str. In each subsequent call that should parse the same string, str must be NULL.
  • 11. Assignment 7 What is strtok() function?  The strtok() function breaks a string into a sequence of zero or more nonempty tokens.  On the first call to strtok(), the string to be parsed should be specified in str. In each subsequent call that should parse the same string, str must be NULL. Prototype: char *strtok(char *str, const char *delim);
  • 12. Assignment 7 Let’s understand how strtok() works:
  • 13. Assignment 7 Let’s understand how strtok() works:
  • 14. Assignment 7 Let’s understand how strtok() works: What will be printed?
  • 15. Assignment 7 Let’s understand how strtok() works: “Are” will be printed O/p of the program: Are
  • 16. Assignment 7 Let’s understand how strtok() works: What will be printed?
  • 17. Assignment 7 Let’s understand how strtok() works: “Are” will be printed “Are” will be printed O/p of the program: Are Are
  • 18. Assignment 7 Let’s understand how strtok() works: But, the next token should be printed is “you” “Are” will be printed “Are” will be printed O/p of the program: Are Are
  • 19. Assignment 7 Let’s understand how strtok() works: What will be printed? What will be printed?
  • 20. Assignment 7 Let’s understand how strtok() works: “you” will be printed “Are” will be printed O/p of the program: Are you
  • 21. Assignment 7 Let’s understand how strtok() works: O/p of the program: Are you How will you print the remaining tokens?
  • 22. Assignment 7 Let’s understand how strtok() works: What is the output?
  • 23. Assignment 7 Let’s understand how strtok() works: O/p of the program: Are You okay
  • 24. Assignment 7 How to implement your own strtok() function?
  • 25. Assignment 7 How to implement your own strtok() function?  Input: str = “Are;you:okay” delim = “;:” A r e ; y o u : o k a y 0 ; : 0 str delim String containing delimiters, these delimiters has to be matched with each and every character of str
  • 26. Assignment 7 A r e ; y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos
  • 27. Assignment 7 A r e ; y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos
  • 28. Assignment 7 A r e ; y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos
  • 29. Assignment 7 A r e ; y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos
  • 30. Assignment 7 A r e ; y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos
  • 31. Assignment 7 A r e ; y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos
  • 32. Assignment 7 A r e ; y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Here at pos 3, delimiter is encountered, so overwrite that byte with ‘0’
  • 33. Assignment 7 A r e 0 y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Return the address using str + start_index and do pos++
  • 34. Assignment 7 A r e 0 y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Return the address using str + start_index and do pos++ Output: Are
  • 35. Assignment 7 A r e 0 y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are
  • 36. Assignment 7 A r e 0 y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are
  • 37. Assignment 7 A r e 0 y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are
  • 38. Assignment 7 A r e 0 y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are
  • 39. Assignment 7 A r e 0 y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are
  • 40. Assignment 7 A r e 0 y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are
  • 41. Assignment 7 A r e 0 y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are
  • 42. Assignment 7 A r e 0 y o u : o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are Here at pos 7, delimiter is encountered, so overwrite that byte with ‘0’
  • 43. Assignment 7 A r e 0 y o u 0 o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are You Return the address using str + start_index and do pos++
  • 44. Assignment 7 A r e 0 y o u 0 o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are You
  • 45. Assignment 7 A r e 0 y o u 0 o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are You
  • 46. Assignment 7 A r e 0 y o u 0 o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are You
  • 47. Assignment 7 A r e 0 y o u 0 o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are You
  • 48. Assignment 7 A r e 0 y o u 0 o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are You
  • 49. Assignment 7 A r e 0 y o u 0 o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are You
  • 50. Assignment 7 A r e 0 y o u 0 o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are You
  • 51. Assignment 7 A r e 0 y o u 0 o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are You
  • 52. Assignment 7 A r e 0 y o u 0 o k a y 0 ; : 0 str delim 0 1 2 3 4 5 6 7 8 9 10 11 12 start_index  Input: str = “Are;you:okay” delim = “;:” pos Output: Are You okay Return the address using str + start_index